Composite Control Question: Re-creating DataGrid child control upon Postback?

D

debartsa

Hi Everybody,

I have a composite control (in C#) which creates a DataGrid child control
that binds to a DataSource (DataSet resultant from a sql query) passed in by
the consuming .aspx. The .aspx page does the typical... if (!Postback)
{ //define datasource and bind } My question is how does my composite
control recreate the DataGrid from ViewState upon postback? i.e. When
postback occurs I can't use the DataSource passed in from the .aspx page?

I've read msdn articles that explain creating a dummy datasource to be used
upon postback? But how do I populated the dummy datasource with the same
values I originally got from my initial sql query?

Thanks for any help!
Sam
 
J

John Saunders

debartsa said:
Hi Everybody,

I have a composite control (in C#) which creates a DataGrid child control
that binds to a DataSource (DataSet resultant from a sql query) passed in by
the consuming .aspx. The .aspx page does the typical... if (!Postback)
{ //define datasource and bind } My question is how does my composite
control recreate the DataGrid from ViewState upon postback? i.e. When
postback occurs I can't use the DataSource passed in from the .aspx page?

I've read msdn articles that explain creating a dummy datasource to be used
upon postback? But how do I populated the dummy datasource with the same
values I originally got from my initial sql query?

On postback, just create the datagrid and add it to your Controls
collection. It will restore from ViewState, same as it saved there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top