OnSelectedIndexChanged event is not firing
Here is the .aspx code snippet.
<tr>
<td></td>
<td class="sectionHeading">
Dashboard</td>
<td> Division  :
<asp:DropDownList ID="ddlDivisions" runat="server" `enter code here`OnSelectedIndexChanged="ddlDivisions_SelectedIndexChanged" Width="152px">
</asp:DropDownList></td>
</tr>
Below is my databinding code. It is called from Page_Load()
'Populate Diviions dropdown
If Not IsPostBack开发者_C百科 Then
ddlDivisions.DataSource = Divisions.Fetch().List
ddlDivisions.DataTextField = "DivisionDesc"
ddlDivisions.DataValueField = "DivisionID"
ddlDivisions.SelectedValue = 3 'Divisioon All
ddlDivisions.DataBind()
End If
Below is my event handler...
Protected Sub ddlDivisions_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlDivisions.SelectedIndexChanged
'Other code goes here
End Sub
Above event handler is not getting called. I have done so far below things as part of my research
- Bind data to datasource of dropdown control when it is not postback
- Control was added from toolbox
- tried adding event handler in .aspx. Still did not work.
Your markup for the DropDownList does not specify the AutoPostBack attribute. This is required to be present and set to true (the default is false):
<asp:DropDownList ID="ddlDivisions" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlDivisions_SelectedIndexChanged" Width="152px">
</asp:DropDownList>
精彩评论