G
Guest
Hi
Instead of a direct opinion on the following matter I prefer to post it as a quiz. What do you expect the code below does:
---
ListItem[] litems = new ListItem[5];
for (int i = 0; i < 5; i++)
litems = new ListItem("text"+i,"value"+i);
DropDownList ddl;
for (int j = 0; j < 3; j++)
{
ddl = new DropDownList();
ddl.Items.AddRange(litems);
//assume PlaceHolder1 exists on WebForm
PlaceHolder1.Controls.Add(ddl);
}
//Now the tricky part - set selectedIndex for 2nd dropdownlist control, let's say:
((DropDownList)PlaceHolder1.Controls[1]).SelectedIndex = 0;
---
So, what do you think is the outcome of the above code?
What do you think of the code/effect semantics in this case?
dimitris
Instead of a direct opinion on the following matter I prefer to post it as a quiz. What do you expect the code below does:
---
ListItem[] litems = new ListItem[5];
for (int i = 0; i < 5; i++)
litems = new ListItem("text"+i,"value"+i);
DropDownList ddl;
for (int j = 0; j < 3; j++)
{
ddl = new DropDownList();
ddl.Items.AddRange(litems);
//assume PlaceHolder1 exists on WebForm
PlaceHolder1.Controls.Add(ddl);
}
//Now the tricky part - set selectedIndex for 2nd dropdownlist control, let's say:
((DropDownList)PlaceHolder1.Controls[1]).SelectedIndex = 0;
---
So, what do you think is the outcome of the above code?
What do you think of the code/effect semantics in this case?
dimitris