S
SJ
Hi,
i'm trying to use codebehind to setup my dropdowns.
myWebFile.aspx has the following code :
<aspropDownList id=test runat=server />
<aspropDownList id=test2 runat=server />
And i'm defining the ListItems like this in codebehind:
for(int i=0;i<3;i++)
{
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?
thanks
-SJ
i'm trying to use codebehind to setup my dropdowns.
myWebFile.aspx has the following code :
<aspropDownList id=test runat=server />
<aspropDownList id=test2 runat=server />
And i'm defining the ListItems like this in codebehind:
for(int i=0;i<3;i++)
{
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?
thanks
-SJ