473,659 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Viewstate of dynamically created controls

My web page contains only a panel control and I add datagrids at runtime.
Viewstate for the datagrids are enabled but every time I postback the page I
have to re bind data to data grids.
I figured out this: (?)
when I do a postback , asp.net looks to the html of the page and can't find
the datagrids. It finds only the panel and loads its state ?

everything is ok until this point .. but ,
my datagrids are not visible at the beginning. I also add buttons to the
page (at run time) . When user clicks to the button I change the visible
property of the datagrid to true. Interesting thing is when user clicks to
another button the first datagrid stays visible. (on page load I change the
datagrids' visible property to false)
Actually this is something I want but I can't understand how does asp.net
figures out which datagrid is visible and which is not ?? If it can remember
that why can't it remember the datagrids on the page ?

Thanx a lot
yufufi,

PS there is no ispostback check on the page.. so only thing different
between postbacks is state.
Nov 18 '05 #1
2 1135
I found this on the web
http://www.tek-tips.com/gviewthread....855/qid/870851

A programmer says
(yes, the reconstructed controls WILL load their old properties from the
ViewState).

this explains why visible datagrids stay visible , but why do I have to
reload their data ???
Nov 18 '05 #2
Understanding ASP.NET ViewState
http://msdn.microsoft.com/library/de.../viewstate.asp

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"yufufi" <yu****@ttnet.n et.tr> wrote in message
news:er******** ******@TK2MSFTN GP10.phx.gbl...
My web page contains only a panel control and I add datagrids at runtime.
Viewstate for the datagrids are enabled but every time I postback the page I have to re bind data to data grids.
I figured out this: (?)
when I do a postback , asp.net looks to the html of the page and can't find the datagrids. It finds only the panel and loads its state ?

everything is ok until this point .. but ,
my datagrids are not visible at the beginning. I also add buttons to the
page (at run time) . When user clicks to the button I change the visible
property of the datagrid to true. Interesting thing is when user clicks to
another button the first datagrid stays visible. (on page load I change the datagrids' visible property to false)
Actually this is something I want but I can't understand how does asp.net
figures out which datagrid is visible and which is not ?? If it can remember that why can't it remember the datagrids on the page ?

Thanx a lot
yufufi,

PS there is no ispostback check on the page.. so only thing different
between postbacks is state.

Nov 18 '05 #3

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

Similar topics

9
21639
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid. Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
3
2424
by: Kenton Smeltzer | last post by:
Hello All, I am having a problem with events and the addition of controls on a page I am developing. First let me tell you what I have tried and then maybe someone can see something I missed. First I tried adding the controls and the event handlers for my control in the Initialize Components method of my page in the hopes that it would fire the event before the
0
2105
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
0
1009
by: Don | last post by:
I need some suggests on how to manage the viewState on my page. I have multiple checkBoxLists that are dynamically created and need then synced up with the viewstate. My problem is that on each postback I may have less items than the viewstate has because some are not created. When the viewState is loaded it seems to load the controls in the order they were created so if the first control is now gone it's data is assigned to what was...
6
2851
by: hlubocky | last post by:
I thought I had a good grasp of the problem related to dynamically creating controls, but it appears that as my application grew in complexity, the problem has resurfaced. As I understand it, in order for a dynamically created control to persist its state, it needs to be created and loaded into the page control hierarchy before the viewstate is loaded. The proposed solution, and that which I have been using, has been to create all of...
6
2058
by: hitendra15 | last post by:
Hi I have created web user control which has Repeater control and Linkbutton in ItemTemplate of repeater control, following is the code for this control On first load it runs fine but when page gets post back it gives following error Failed to load viewstate. The control tree into which viewstate is
1
2498
by: Andrew Robinson | last post by:
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...
3
2579
by: HP | last post by:
Hi there The problem of dynamically created controls vs viewstate is widely known one. To access values of controls they have to be recreated on Page_Load. Unfortunately it causes many problems in the following (rather common, I guess) scenario: The controls are created dynamically. Their number and contents
2
2207
by: Dica | last post by:
i've got a simple page with a dropdown list of employees and a series of checkboxs showing their skills. the checkboxs are created dynamically from a sql statement and viewstate = false is set on each one. once the dropdown changes from one employee to another, the checkboxes are all recreated and i check the database to see if that particular employee has that skill. if so, i set the checkbox's checked state to true. however, when i look...
0
2227
by: Scott Roberts | last post by:
I always thought that the viewstate "keys" included the control ID. As long as the control IDs were unique, there shouldn't be any conflicts. Well, it appears that that may not be the case with dynamic controls. Our application was having a problem very similar to the one described here: http://weblogs.asp.net/alessandro/archive/2008/01/04/failed-to-load-viewstate-typical-problem-with-an-obvious-solution.aspx Unfortunately, the "fix"...
0
8850
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.