473,546 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ViewState Problem

Hi,
I have a page with one DropDownList and a Placeholder.Thi s 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 to show this updated list in
the static DropDownList I need to re-populate the DropDownList again.As one
value from this list gets removed its selected value is now different.The
value in dynamic control should also change, so I re-populate the list at
placeholder also.
Now the problem is that when I select a value in dynamic DropDownList,
it does not get selected.Always the first value in the list is selected
though I select any other value.That means the viewstate for this dynamic
DropDownList does not persist.
Please tell me how to get the correct selected value from this dynamic
DropDownList after re-populating it if any one can.
I am using ASP.NET with C#.

Thanks in advance,
Kalyani

Nov 19 '05 #1
1 1302
You need to store the Selected Index of the drop-down list in something that
IS persistent in the page, like the Page's ViewState, and then restore it
yourself via code when you re-insert the Drop-down list. Remember that the
name "ViewState" implies saving the state of the Page as it was in the last
Response.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Kalyani" <Ka*****@discus sions.microsoft .com> wrote in message
news:F2******** *************** ***********@mic rosoft.com...
Hi,
I have a page with one DropDownList and a Placeholder.Thi s
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 to show this updated list in
the static DropDownList I need to re-populate the DropDownList again.As
one
value from this list gets removed its selected value is now different.The
value in dynamic control should also change, so I re-populate the list at
placeholder also.
Now the problem is that when I select a value in dynamic DropDownList,
it does not get selected.Always the first value in the list is selected
though I select any other value.That means the viewstate for this dynamic
DropDownList does not persist.
Please tell me how to get the correct selected value from this dynamic
DropDownList after re-populating it if any one can.
I am using ASP.NET with C#.

Thanks in advance,
Kalyani

Nov 19 '05 #2

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

Similar topics

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...
2
2805
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We intermittantly get the following exception - EXCEPTION MESSAGE: The viewstate is invalid for this page and might be corrupted. STACK TRACE:
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,...
2
1979
by: Janaka | last post by:
We have managed to lock down 99% of the application errors occurring in our asp.net sites. The only errors which occur on a regular basis now are viewstate errors. We have disabled viewstate on the majority of pages but kept them where absolutely necessary, such as shopping carts, adding items, etc. Also we've made sure the following have...
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...
2
3935
by: epigram | last post by:
I'm responding to a button click event on an asp.net web form. I then need to retrieve the value from a TextBox control and I want to compare it against the control's previous value to see if it has changed. How can I retrieve a control's previous value from the ViewState? I know that I could save the control's previous value in a session...
6
2843
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...
1
7588
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my usercontrol is a button and a label. Everytime the button is clicked a counter which is stored in the viewstate is increased and displayed in the...
0
2223
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: ...
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
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
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
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...
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
3492
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...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.