Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dynamic LinkButton, ViewState

Reply
Thread Tools

Dynamic LinkButton, ViewState

 
 
Andrew Robinson
Guest
Posts: n/a
 
      06-16-2006
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


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      06-17-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with ViewState: "function 'ViewState.get_Item' evaluated and returned null" Steph ASP .Net 2 05-11-2011 02:35 PM
Errors: Failed to load viewstate. & Validation of viewstate MAC failed. sck10 ASP .Net 6 09-01-2006 05:59 PM
Loading usercontrols, viewstate problem, slighly different from all others "viewstate uc problems" please help... ujjc001 ASP .Net 0 07-27-2005 01:52 PM
Viewstate errors... how do I get viewstate working? mark ASP .Net Building Controls 0 02-20-2004 02:17 PM
Corrupted ViewState (Yes, another issue concerning viewstate) Ben Rush ASP .Net 2 12-05-2003 04:17 PM



Advertisments