我有一个DropDownList
会被多次使用的,所以我有一个selection_change
属性。现在,我试图让用户在列表中选择一个文件 ID。然后我使用他选择的 id 并运行一个存储过程。我第一次移动文件时它可以工作,但第二次(当他选择另一个文件时)它失败了。我的问题是如何用值重新分配 javascriptselection_change
值?
这是我的功能:
function getCaseFiles(canMoveExpenses) {
//create Popup with content from div
$('#ddlFiles').dialog({
autoOpen: true,
height: 'auto',
width: 'auto',
modal: true,
buttons: {
"Ok": function () {
// var newCaseDdl = document.getElementById("ddlCaseFilesNew");
// var newCaseDdlInt = newCaseDdl.options[newCaseDdl.selectedIndex].value;
var newCaseDdl = ddlCaseFilesNew.options[ddlCaseFilesNew.selectedIndex].value;
alert("newCaseDdl = " + newCaseDdl);
var oldCaseFile = $("#hidCaseFile").val();
alert(oldCaseFile);
if (newCaseDdl != -1) {
moveCasefile(canMoveExpenses, newCaseDdl, oldCaseFile);
$(this).dialog('close');
}
else {
showMessage("Error. Please Select a Value From The Lists.");
}
},
Cancel: function () {
newCaseDdl = null;
oldCaseDdl = null;
$(this).dialog('close');
}
}
});
}
我的下拉列表 div:
<div id="ddlFiles">
<label>
Select new CaseFile:</label>
<asp:DropDownList runat="server" ID="ddlCaseFilesNew" DataSourceID="dsCaseFiles"
DataTextField="Display" DataValueField="FileID"
OnPreRender="ddl_PreRender"
Width="300px" />
</div>
下拉列表背后的代码:
if (Request.QueryString["ExpenseID"] != null)
{
if (!IsPostBack)
{
ddlCaseFilesNew.DataSourceID = "dsCaseFiles";
ddlCaseFilesNew.SelectedIndex = -1;
ddlCaseFilesNew.DataTextField = "Display";
ddlCaseFilesNew.DataValueField = "FileID";
ddlCaseFilesNew.DataBind();
ddlCaseFilesNew.Attributes.Add("onchange", "getValue();");
}
}