By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

Itemplate viewstate

P: n/a
Hello,
I am trying to create textbox control dynamically into a datagrid.
I do not know the number of columns until run time so I thought I could use
template columns dynamically and add them into the datagrid.
This works fine, but on post back all the data in the datagrid disappears.
Any idea why? I have the bad feeling that the view state has something to
do with it.
I do have viewstate enabled.
Note: I am implementing the Itemplate interface and I have Implemented the
InstantiateIn mehod.
Thanks!

Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Controls which are created dynamically must be recreated dynamically on
postback in order to exist.

One solution is to use the OnItemCreated even to create the controls:
http://openmymind.net/databinding/index.html#4.3

Another might be to use Denis Bauer's free dynamic control placeholder,
which might do the trick:
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Amine" <Am***@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hello,
I am trying to create textbox control dynamically into a datagrid.
I do not know the number of columns until run time so I thought I could use template columns dynamically and add them into the datagrid.
This works fine, but on post back all the data in the datagrid disappears.
Any idea why? I have the bad feeling that the view state has something to
do with it.
I do have viewstate enabled.
Note: I am implementing the Itemplate interface and I have Implemented the
InstantiateIn mehod.
Thanks!

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.