473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

.Selected property for listbox does not work

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
vi********@hotmail.com

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

/// <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[i];
lstFill.Items.Add(liAdd);
lstFill.Items[i].Selected = false;
if (alSelectionIds.Contains(liAdd.Value)) {
lstFill.Items[i].Selected = true;
}
}
}
catch (Exception ex) {
throw ex;
}
finally {
liAdd = null;
}
}

-------------------------------------------------
Nov 19 '05 #1
0 939

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Vipin Kedia | last post by:
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...
3
by: DD | last post by:
I have a mainform with a subform. > The main form has a dropdown box "chooseMonth", in the afterupdate event > i requery the subform so all records with the same date are viewed. > Now i only want...
2
by: Peder Y | last post by:
Anyone knows if there is some kind of property or function that will return the last selected/deselected item/index in a multiselect ListBox? SelectedIndex will point to first index in the...
2
by: Alpha | last post by:
How do I change the selected item in a listbox according to a Combox's selected item on the same form? The Combox is from a different table in the same dataset as the Listbox uses. Combox's...
1
by: Matthew Louden | last post by:
I created a listbox with multiple selectionmode property, but I have trouble to get a list of selected values. The following only gets the first selected value, not others. TextBox2.Text =...
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
5
by: Paul | last post by:
Hi I have a listbox and have the selection mode set to multiple in the property box. I am trying to set multiple selected values in code but it only seems to use the last one....
3
by: David L Wright II | last post by:
I have a data bound listbox that I want to select multiple lines then process each line. I bound a two column datatable to the listbox and set the DisplayMember property to the appropriate column...
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
3
by: peter.mosley | last post by:
I've tried googling for the answer to this problem, without any luck. I'm sure the truth must be out there somewhere! I have a multiselect listbox populated with many items (set by the RowSource...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.