473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Dynamic LinkButton, ViewState

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
Jun 16 '06 #1
1 2484
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

Jun 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tomas Vera | last post by:
Here's another goofy thing. I need to persist the state of items added dynamically to a Panel control between round-trips to the server. I have a web form that contains a TreeView and a...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
2
by: Shiju Poyilil | last post by:
I have a link button "lButton" created dynamically at the item databound event of the data grid "datagrid1" in the footer.so i want to execute the item command event of the datagrid on clicking...
2
by: cindy | last post by:
I have a web form with 3 links, depending on which link is clicked a user control loads, page1.ascx,page2.ascx,page3.ascx page1.ascx does a search, uses 3 asp:dropdownlists with viewstate true...
6
by: Andrew Robinson | last post by:
I have a page that contains a number of link buttons that are used for making selections. I load my LinkButtons during the Page_PreInit event and they render fine but then I need to make a change...
1
by: JeffP | last post by:
I need to know when a link buttons value is zero so I don't try to run a query to find none. When I was using ViewState(ds_Last), which I can't do because certain phones are choking on the data,...
13
by: rn5a | last post by:
In a shopping cart app, suppose a user has placed 5 orders, I want to show him 5 LinkButtons (one for each order) so that when he clicks the first LinkButton, he would be shown the details of his...
6
by: ree321 | last post by:
I have a linkbutton which is added to a column in a datagrid dynamically using a template I created. When I change the data in it by not databinding and then when I later retreive the data from the...
0
by: danielhamd | last post by:
Hello - I am having some trouble with dynamic controls in Asp.Net. I have a form for a user to enter certain information. When this information is posted back, it is shown on the page by...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.