开发者

OnSelectedIndexChanged event is not firing

Here is the .aspx code snippet.

                <tr>
                   <td></td>
                   <td class="sectionHeading">
                       Dashboard</td>
                    <td> Division &nbsp: &nbsp;&nbsp;
                        <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

  1. Bind data to datasource of dropdown control when it is not postback

  2. Control was added from toolbox

  3. 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜