我有一个下拉列表,我使用JQuery,AJAX webservice绑定它们,但是当我试图在SelectedIndexChange上检索该DropDownList的选定值时。我得到0(零)
绑定DropDownList之前
<asp:DropDownList ID="ddlbillNumber" runat="server" OnSelectedIndexChanged="ddlbillNumber_SelectedIndexChange"
AutoPostBack="true" >
<asp:ListItem Value="0" Text="--Select--"></asp:ListItem>
</asp:DropDownList>
JSON&amp; AJAX代码:
function GetBillNumbers() {
//debugger;
var ClientName = $("#<%=HiddenFieldCompanyId.ClientID %>").val();
$.ajax({
type: "POST",
url: "<%=mstr_WebsitePath%>webservice/ClientSearch.asmx/GetClientBillNumber",
data: "{ 'ClientName' : '" + ClientName + "' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var ddlbillNumber = $("[id*=ddlbillNumber]");
ddlbillNumber.empty().append('<option value="0">--select--</option>');
$.each(r.d, function () {
ddlbillNumber.append($("<option></option>").val(this['Value']).html(this['Text']));
});
}
});
}
在浏览器代码中绑定DropDownList后:
<select name="ddlbillNumber" id="ctl00_body_ddlbillNumber">
<option value="0">--select--</option>
<option value="VMPL/Delhi/001/15-16">VMPL/Delhi/001/15-16</option>
</select>
然后我选择第二个选项意味着VMPL / Delhi / 001 / 15-16但是获得0 代码:
Protected Sub ddlbillNumber_SelectedIndexChange(ByVal sender As Object, ByVal e As EventArgs)
Dim Bill As String = ddlbillNumber.SelectedItem.Value // Here I am getting zero
If Bill <> "" Then
Dim Vasundhara As String = Bill.Substring(0, 2)
If Vasundhara = "VI" Then
GetInfotechBill(Bill, 1)
ElseIf Vasundhara = "VM" Then
GetInfotechBill(Bill, 0)
End If
PanelPrintDuplicatBill.Visible = True
End If
End Sub