我有一个DropDownList
将被多次使用,所以我有一个selection_change
属性。现在,我试图让用户在列表中选择文件ID。然后我使用他选择的id并运行存储过程。我第一次移动它工作的文件,但第二次(当他选择另一个文件时)它失败了。我的问题是如何将javascript值重新分配给selection_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();");
}
}