clearing viewstate for individual controls
I have a listbox thats databound, the data behind will chnage depending on the results of other listboxes.
The probem is I have set enabledviewstae = true and if you select a value and on the next data pull this value isnt included then i get the error
"Specified argument was out of the range of valid values."
I need to know how to clear the viewstate for this one control before databinding
Re: clearing viewstate for individual controls
Why don't you just rebind the control?
Re: clearing viewstate for individual controls
I am doing but heres an example of the problem:
dropdown is bound and user selects an option "Yellow"
Yellow is then stored in the viewstate for this control.
Things happen on the page and controls gets bound to a different version of the data that doesnt include "Yellow"
.NET then trys to set the controls selected item to "Yellow" as this is stored in viewstate and is erroring as "Yellow" no longer exists
Re: clearing viewstate for individual controls
So even if you did something like this:
VB Code:
'' somewhere in code
''
drpMyDropDownList.DataSource = dtaSomeDataSet
drpMyDropDownList.Bind()
Otherwise, is EnableViewState a read only property at runtime or could you change it to False and then back to True and perhaps that might clear it?