GridView w/ ITemplate Columns - Can't find data on Postback



I'm dynamically creating all the Columns in a GridView at run time and
binding it to a DataTable. I have to build it at runtime (using an
ITemplate subclass) because the number of columns is based on User
input. All column cells are rendered as Textboxes. All Textboxs & the
Grid have EnableViewState = True;

Everything works fine except on Postback I can't seem to find the
embeded Textbox controls that are needed to determine what the user
has changed and be able to update the underlying Data table. Do
Dynamically rendered controls come back in Viewstate???? They must,
but I can't find them.

on Page_Load (if it is a Postback) I build/rebuild the GridViews
columns (I also tried in CreateChildControls)
I do not bind the Data here because any user changes would be

in Page_PreRender I try to Access the rows of the GridView but
MyGrid.Rows.count = 0
My intent is to update the DataTable with any cahnges and then Rebind

Where can I access the Data the user entered on the Page?

Thanks for any help!!




I had the same issue recently with the GridView. I ended up using a third
party grid from Infragistics. This grid control has a RestoreTemplate event
that you can use to restore all of your ITemplate based columns during a


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