dynamic columns disappears after postback
You should create dynamic controls in RowCreated instead of RowDataBound because this event gets fired on every postback whereas RowDataBound
only will fire when the GridView
gets databound to it's DataSource
.
Dynamically created controls must be recreated on every postback with the same ID as before, then they retain their values in the ViewState and events will fire correctly(f.e. a DropDownList's SelectedIndexChanged
event).
So you should create them in RowCreated
and "fill" them in RowDataBound
(f.e. the DropDownList
datasource/Items or a TextBox
-Text).