SelectedIndex of DropDown list not setting correctly in C#
In my aspx form, I am returning to a page with several dropdown boxes, and
I want to set the values back to what was previously selected before
leaving the page.
I am returning the SelectedIndex values through URL parameters which I
successfully pickup in my code:
string OldValue = Request.QueryString["OldValue"].ToString();
OldValue accurately takes on the correct value. However, when I try to set
the dropdown SelectedIndex to this value, I continually get SelectedIndex
set to "-1"
Example (temporarily bypassing the QueryString and using a value directly):
ddlSearchCollege.SelectedIndex = 3;
I have a breakpoint here, and when I hover the mouse over SelectedIndex,
the value shows as "-1" instead of 3.
No comments:
Post a Comment