Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Can anybody explain this problem?


Message #1 by "Anders Hedstrom" <anders.hedstrom@b...> on Tue, 2 Jul 2002 12:16:44
Hi all,

I have a small problem that I hope someone can explain to me...

I load an ListArray with ListItems to 2 different DropDownLists in my 
PageLoad method. Then I select 2 different indexes in the 2 DropDownLists -
 but when the page displays it is the same Item selected in both 
DropDownLists....why? 

Here some code example:

// loads list from db
for(IEnumerator ienum = this.GetList().GetEnumerator();ienum.MoveNext();)
{
 ListItem li = (ListItem)ienum.Current;
 this.ddl1.Items.Add(li);
 this.ddl2.Items.Add(li);
}

this.ddl1.SelectedIndex = 1;
this.ddl2.SelectedIndex = 4;

And if I do like this it works fine:

for(IEnumerator ienum = this.GetList().GetEnumerator();ienum.MoveNext();)
{
 ListItem li = (ListItem)ienum.Current;
 this.ddl1.Items.Add(li);
}

for(IEnumerator ienum = this.GetList().GetEnumerator();ienum.MoveNext();)
{
 ListItem li = (ListItem)ienum.Current;
 this.ddl2.Items.Add(li);
}

this.ddl1.SelectedIndex = 1;
this.ddl2.SelectedIndex = 4;


Plz....can anyone explain this....??

//Anders =)

  Return to Index