Home All Groups Group Topic Archive Search About

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

Author
31 Oct 2008 12:39 PM
John
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
overwritten

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!!
-John

Author
3 Nov 2008 11:37 AM
myles
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
postback.

Myles


Show quoteHide quote
"John" <1944***@gmail.com> wrote in message
news:45e7e827-3fd0-4392-b7a8-9962b24b4e48@r37g2000prr.googlegroups.com...
> 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
> overwritten
>
> 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!!
> -John
>
>
>
>