ASP.NET ListBoxes, SelectedValue and ViewState
Posted by: Rick Strahls WebLog,
on 18 Mar 2006 |
View original
Aarrgh. Am I the only one who's repeatedly cursing the way ListBoxes and the OnSelectedIndexChanged event and SelectedValue assignments work in ASP.NET when ViewState is off?
If you turn off ViewState on a ListBox or DropDownList control it's a real bitch to deal with the OnSelectedIndexChanged event. Take the following scenario assuming you set ViewState off for the lstCustomers control:
protected void Page_Load(object sender, EventArgs e)
{
Customer = new busCustomer();
...