DropDownList doesn't postback on SelectedIndexChanged

后端 未结 4 1810
臣服心动
臣服心动 2021-01-11 15:28

I\'m writing an ASP.Net webform with some DropDownList controls on it. Then user changes selected item in one of dropdowns, ASP.Net doesn\'t seem to handle SelectedIndexChan

4条回答
  •  别那么骄傲
    2021-01-11 15:58

    You need to set the AutoPostBack property of the list to true.

    Also, if you're populating the contents of the drop down list from the code behind (getting the contents of the list from a database, for example) - make sure you're not re-binding the data in every postback.

    Sometimes people are caught out by binding the drop-down in the page load event without putting it in an If Not IsPostBack. This will cause the event not to fire.

    The same is also true of repeaters and ItemCommand events.

提交回复
热议问题