Search code examples
.netasp.netgridviewdrop-down-menuascx

Adding Event Handler to DropDownList inside GridView - how to?


I have DropDownList inside GridView. Now I would like to add event handler for dropdownlist which would react on SelectedIndexChanged. I'm nesting DropDownList inside GridView by using RowDataBound event for GridView. (http://www.highoncoding.com/Articles/169_DropDownList_Inside_GridView__Method_1_.aspx) Can anybody help me, and tell me how to add event handling for dropdownlist, please?


Solution

  • ok, the issue I've had is solved. To handle SelectedIndexChanged for DropDownList nested inside GridView you have to just set AutoPostback property to true and point SelectedIndexChange event to some procedure.

    The cause of issue I had was that I didn't check in Page_Load function (during binding data to GridView) following rule: If Not Page.IsPostBack Then. And that's all. So don't forget to do it please! :)