473,480 Members | 3,135 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sync viewstate when controls are removed

Don
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 the second control.

I'll give an example:I have a parent checkBoxList that shows States in
the United States. For each State that is checked I get another
checkBoxList with the cities in that state.
Suppose the user clicks Iowa. I postback occurs and I dynamically
create another checklist box for the cities in Iowa and populate it
from the database.
Now the user clicks Ohio, a postback occurs and I loop thorugh the
selected states and create controls from each of them. The viewStates
handles loading the data back for Iowa (and preserves data and checked
boxes) and I load Ohio from the database.
All of this works find and postbacks do not cause a problem.

Now, assume the user removes the check by Iowa so I now longer want to
display the cities in Iowa. During the postback I loop through the
selected states and find only Ohio. I then create one checkBoxList for
Ohio but when the page loads I notice the Ohio checkBoxList has the
cities for Iowa.

This is because the viewState loads controls in the order they were
first put on the page.
How can I get the applciation to skip those that are not created? It
would be best if the viewState used the id rather that the order items
were added.
How can I access the items on the viewState? If I can get the parent
Control from the viewState I can tell what was checked the last time
and create these controls, then I'll remove the ones that need to be
removed.
Can anyone offer any suggests?

I've tried overwriting loadViewState and saveViewState but I always get
this result.

Thanks,
Don

Nov 19 '05 #1
0 1003

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

Similar topics

2
4865
by: theo | last post by:
Hi... I wish to extract the text content of an Xml file and assign it to DropDownList controls at runtime.I can get the Xml file text content into the DropDownList controls (Ex...if 5 Xml text...
9
21624
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...
3
2626
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
10
2239
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and...
8
4261
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
6
2718
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a...
1
1298
by: Kalyani | last post by:
Hi, I have a page with one DropDownList and a Placeholder.This placeholder wil contain either a textbox or a DropDownList depending upon the value in previous DropDownList. Also there is a Submit...
6
4397
by: Peter Zolja | last post by:
Hi, I'm building a webcontrol that contains a dynamic list of other controls. My problem is that when I add or remove an item the synchronization between the ViewState and the Controls...
0
7055
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
6920
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...
1
6763
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...
0
7030
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
5367
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,...
0
4503
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...
0
1313
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 ...
1
574
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
210
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...

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.