Custom Datagrid Help! Header text disappears on Post Back!
-
Hi All, I am creating a custom Datagrid but on any postback all of the text for the Header disappears! If I do a "this.Parent.Page.DataBind()" the header reappears...but I lose all of the data changes that were made to the datagrid! Any ideas as to why a postback would clear out my header? And how I can fix this? Many thanks in advance! BTW, Mihir, I really appreciate all of your help... your suggestions for my other problem helped alot and that part is working now :o)
-
Hi All, I am creating a custom Datagrid but on any postback all of the text for the Header disappears! If I do a "this.Parent.Page.DataBind()" the header reappears...but I lose all of the data changes that were made to the datagrid! Any ideas as to why a postback would clear out my header? And how I can fix this? Many thanks in advance! BTW, Mihir, I really appreciate all of your help... your suggestions for my other problem helped alot and that part is working now :o)
Hi there, When you call the
DataBind
method, you can force the datagrid to build its control hierarchy based on the specify datasource. When the page posts back, you need to provide your logic to build the control hierarchy again. To do that you simply override theCreateChildControls
method in your custom datagrid, and provide your logic in there. You can see the document for more information: Developing a Templated Data-Bound Control [^]