Question store a DropDown List control in View State

josephjohn100

Member
Joined
Nov 8, 2012
Messages
8
Programming Experience
3-5
Can I store a DropDown List control in View State ?

Dim ddl As DropDownList = DirectCast(e.Item.FindControl("drpCountry"), DropDownList)
ViewState("drpNewBU") = ddl 'Getting Error here


How can I achieve this ?


Thanks
-John
 
You wouldn't store a control in view state. You might store the state of a control in view state, which is exactly what view state is for, i.e. the state of the view. Build the view as you normally would and then configure it based on view state. That means storing the current selection, not the whole control.
 
Back
Top