Developing a Templated Data-Bound Control
-
hey all, i read the MSDN article "Developing a Templated Data-Bound Control", the problemis on creating the child controls logic from the ViewState, in the article they create the DataSource from a dummy class that actully has no data!!! i think that they just implemented anything that represent the DataSource that is saved in the ViewState, but in real implementation we have to save the DataSource from the user and reload again in postbacks, is what i am saying true or i'm missing something?!
-
hey all, i read the MSDN article "Developing a Templated Data-Bound Control", the problemis on creating the child controls logic from the ViewState, in the article they create the DataSource from a dummy class that actully has no data!!! i think that they just implemented anything that represent the DataSource that is saved in the ViewState, but in real implementation we have to save the DataSource from the user and reload again in postbacks, is what i am saying true or i'm missing something?!
Hi there, In fact, the data source is used to create the control hierarchy for the first time, later on this hierarchy is built based on the ViewState, you can see more details in the CreateControlHierarchy method. Have you tried to watch the DataSource property value of a datagrid when the page posts back to the server? You'll see that you don't need to persist the datasource. If the user disables the ViewState, he will then have to bind the datasource again when the page posts back to the server. You can read a great article in CP written by Rob van der Veer that might give you some good ideas http://www.codeproject.com/aspnet/ObjectRepeater.asp[^]