Hi,
generate it so that you create controls in page_load, but set any proeprties
after you have added the control to Controls collection so that ViewState
tracking has started. And such, state dependant properties need to be set
only once inside If Not IsPostBack check (!IsPostBack in C#), e.g
initially..
here are a some references
Understanding ASP.NET ViewState
http://msdn.microsoft.com/library/de.../viewstate.asp
Dynamic Web Controls, Postbacks and ViewState
http://aspnet.4guysfromrolla.com/articles/092904-1.aspx
Dynamic Controls in ASP.NET
http://aspnet.4guysfromrolla.com/articles/081402-1.aspx
Working with Dynamically Created Controls
http://aspnet.4guysfromrolla.com/articles/082102-1.aspx
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:ub**************@TK2MSFTNGP03.phx.gbl...
I have a <asp:table> control with a large number of dynamically created
LinkButtons. I am using the command event, command name and command
argument values in my LinkButtons to trigger actions after the post back.
The table is dynamically generated based on a key field that is stored in
ViewState. This key field is updated by several other controls on the same
page.
I am struggling with the pattern of when to create the table. I can't load
it in Page_Init as ViewState is not restored. If I load it at Page_Load
time, I seem to be getting the command name/arguments from the previous
postback and at times, my dynamic LinkButton fails to fire the command
event.
Any suggestions would be appreciated. Thanks,
Andrew