DropDowns: Setting index
i'm trying to use codebehind to setup my dropdowns.
myWebFile.aspx has the following code :
<asp:DropDownList id=test runat=server />
<asp:DropDownList id=test2 runat=server />
And i'm defining the ListItems like this in codebehind:
test.Items.Add(new ListItem(i.ToString(), i.ToString()));
test2.Items.Add(new ListItem(i.ToString(), i.ToString()));
And finally setting the selected value like this :
test.SelectedIndex = 1;
test2.SelectedIndex = 2;
Except the code above doesnt work as expected and sets BOTH test and test2
with a SelectedIndex of 2.
Any ideas why this would happen?
|All times are GMT. The time now is 06:52 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.