I'm trying to store a dropdownlist control in viewstate. Not the selected value, but the control.
protected void ddl_selectedindexchanged(object sender, EventArgs e)
ViewState["sender"] = (dropdownlist)sender;
That gives an error as dropdownlist is not serializable. So as someone suggested, I tried this
ViewState["sender"] = ddl.ID;
but when trying to retrieve it, the value of ddl is null.
dropdownlist ddl = (dropdownlist)findcontrol(ViewState["sender"].tostring());
what is the right way to do this.