Multiple Dropdownlist, selectedindex all the same but should be different

L

Linna

Hi,

I am actually binding to an ArrayList as below. The ArrayList stores
arrays of size 2. The thing is it works fine on postbacks. It's just
the first load that it defaults the 3 selected value to the last
selectIndex.

Thanks!
Linna


ArrayList alQuery = new ArrayList();
alQuery = oCust.RetrieveSavedQueryList();
IEnumerator myEnum = alQuery.GetEnumerator();

int i=0;
while ( myEnum.MoveNext() )
{
string[] item = new string[2];
item = (string[])myEnum.Current;
ListItem li = new ListItem(item[1],item[0]);
//default to selected view for first load
ddlView1.Items.Add(li);
ddlView2.Items.Add(li);
ddlView3.Items.Add(li);
if (String.Compare(item[0],_defaultView1,true)==0)
{
i1 = i;
}
if (String.Compare(item[0],_defaultView2,true)==0)
{
i2 = i;
}
if (String.Compare(item[0],_defaultView3,true)==0)
{
i3 = i;
}
i++;
}
ddlView1.DataBind();
ddlView1.SelectedIndex = i1;
ddlView2.DataBind();
ddlView2.SelectedIndex = i2;
ddlView3.DataBind();
ddlView3.SelectedIndex = i3;
 
E

Eliyahu Goldin

Linna,

As I said, the problem is in sharing the same items between several ddls.
When you make an item selected in one ddl, it becomes also selected in the
others. Make separate instances of ArrayList for every ddl.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top