Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > .Selected property for listbox does not work

Reply
Thread Tools

.Selected property for listbox does not work

 
 
Vipin Kedia
Guest
Posts: n/a
 
      02-11-2005
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
http://www.velocityreviews.com/forums/(E-Mail 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[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;
}
}

-------------------------------------------------
 
Reply With Quote
 
 
 
 
Sean McKaharay
Guest
Posts: n/a
 
      02-14-2005
sounds to me that you are having a timing problem. you are creating the the
list in the wrong spot. Check out this article and that should help:

http://aspnet.4guysfromrolla.com/articles/092904-1.aspx




"Vipin Kedia" <Vipin (E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 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[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;
> }
> }
>
> -------------------------------------------------



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing image src property does not work in IE? reynardmh@gmail.com Javascript 2 06-07-2006 08:53 PM
.Selected property for listbox does not work =?Utf-8?B?VmlwaW4gS2VkaWE=?= ASP .Net 0 02-11-2005 06:23 AM
.Selected property for listbox does not work Vipin Kedia ASP .Net Building Controls 0 02-11-2005 06:23 AM
property atribute does not work Bart ASP .Net Building Controls 0 12-15-2004 05:23 PM
Listbox item added with client scripts not submitting with ASP:Listbox Simon Prince ASP .Net 2 10-19-2004 04:11 PM



Advertisments