ViewState Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 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
 
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.
 
Back
Top