473,546 Members | 2,244 Online
Bytes | Software Development & Data Engineering Community
+ 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 1008

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

Similar topics

2
4878
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 tags then 5 dropdownlist controls each containing the 5 Xml text tags). Problem,when I save the user DropDownList selected items by means of a...
9
21630
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...
3
2633
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 and this causes control B to be created, when this is done the VIEWSTATE is lost for CONTROL B. In the EVENT that causes CONTROL B to be created...
10
2247
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 disable the session state in Web.Config the VIEWSTATE variable is still maintained and stores some values. Can anyone tell what those values are for,...
8
4265
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 which is related to the repeater. In the code shown below, if I call Repeater1.Controls.Count in the OnInit (the code fragment was highlighted in...
6
2732
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 placholder and the user clicks on a specific control outside of the usercontrol and some Javascript is run where a hidden variable is changed to...
1
1302
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 button and on click of this event values in thse controls are processed and selected value in previous DropDownList ( static one ) gets removed. Now...
6
4403
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 collection seems to break -- or at least that's my theory for now. Here's what I do; to add an item I do that following on the PostBack of a button: 1....
0
7507
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7698
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. ...
0
7794
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6030
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...
1
5361
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...
0
5080
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...
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
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...

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.