SelectedIndexChanged event doesn't fire

2019-07-30 02:12发布

I have added the AutoPostBack = "true" attribute to the drop down list. It doesn't work.

<asp:DropDownList CssClass="dropDownList" ID="ddlBusinessUnit" 
                  AutoPostBack="true" runat="server" Width="250px"   
                  OnSelectedIndexChanged="ddlBusinessUnit_SelectedIndexChanged">
</asp:DropDownList>

code behind:

Protected Sub ddlBusinessUnit_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    Response.Write("Hello")
End

How can I ensure that the event method is called?

1条回答
一夜七次
2楼-- · 2019-07-30 02:33

Are you populating your Dropdownlist on every Postback?

Use IsPostBack to check whether the page is loaded for the first time or not.

If Not IsPostBack Then
   BinDdlBusinessUnit()
End If
查看更多
登录 后发表回答