PostBack and selection in DropDownList control (ASP.NET 2.0)
Sometimes a simple task can take plenty of time. And today I tried to use DropDownList control without ViewState (in other words - by "manually" populating the combobox on each page loading). By some reason, DropDownList control is not raising SelectedIndexChanged event if EnableViewState is False, and I'm not sure how to do it properly in ASP.NET way...
As workaround I used the control-name/value pair for the drop-down which is passed in HTTP POST parameters (when form is submitted). Control-name is UniqueID property of the drop-down, and the value contains the selected item.
So to restore the selection I used:
Let me know if you know a better solution.
As workaround I used the control-name/value pair for the drop-down which is passed in HTTP POST parameters (when form is submitted). Control-name is UniqueID property of the drop-down, and the value contains the selected item.
So to restore the selection I used:
_combo.SelectedValue = Request[_combo.UniqueID];
Let me know if you know a better solution.
0 Comments:
Post a Comment
<< Home