.Selected property for listbox does not work

G

Guest

Hi
I have written a code for showing the list boxes as selected using a
Listitem and the selected property of the items.
Now I have 2 list boxes in my page. But it shows only the selected values
of the last list box in both the list boxes.
If i reverse the calls to the filllistbox methods it shows the value
selected for the 1st list box in both the listboxes.
I have the code for my method below. Is there a way I can solve this
problem?

The method calls are as follows :-

this.FillListBox(myModel.CustomerLBUserList, myModel.SelectedPRList,
this.lstProofreaders);

this.FillListBox(myModel.CustomerLBUserList, myModel.SelectedRevList,
this.lstReviewers);


Thanks in advance
Vipin Kedia
(e-mail address removed)

-------------------------------------------------

/// <summary>
/// This is overloaded method.
/// This method fills the data as well as preselects item.
/// Note: This method will throw exception if selection mode is single
and selection arraylist contains multiple items for selection
/// </summary>
/// <param name="alData">The ArrayList of ListItem with which ListBox
needs to be populated</param>
/// <param name="alSelectionIds">The ArrayList of Ids which needs to be
selected</param>
/// <param name="lstFill">The ListBox</param>
public void FillListBox(ArrayList alData, ArrayList alSelectionIds,
ListBox lstFill) {
ListItem liAdd = null;
try {
lstFill.ClearSelection();
lstFill.Items.Clear();
for (int i=0; i<alData.Count; i++) {
liAdd = (ListItem) alData;
lstFill.Items.Add(liAdd);
lstFill.Items.Selected = false;
if (alSelectionIds.Contains(liAdd.Value)) {
lstFill.Items.Selected = true;
}
}


}
catch (Exception ex) {
throw ex;
}
finally {
liAdd = null;
}
}

-------------------------------------------------
 

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

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top