943,625 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 1084
  • ASP.NET RSS
Feb 16th, 2009
0

Speedup CheckBoxList search

Expand Post »
I want to speed ChechBoxList's getting the selected items, the normal approach is
c# Syntax (Toggle Plain Text)
  1. foreach (ListItem li in checkListBox.Items)
  2. {
  3. if (li.Selected)
  4. {
  5. }
  6. }
but if I've 6000 items in the CheckListBox, that's mean I should go through the 6000 items to know which is selected. Performance POOOOOOR!!!
Is there way to get just selected ItemsCollection ??
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Feb 16th, 2009
0

Re: Speedup CheckBoxList search

That was abount the most stupid post I have sent

I think I will edit it out
wish there was a delete button
Last edited by almostbob; Feb 16th, 2009 at 10:28 am.
Reputation Points: 562
Solved Threads: 367
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Feb 17th, 2009
1

Re: Speedup CheckBoxList search

I dont think there is a built in method to get selected ItemsCollection only. Even if there is one, the algorithm would be the same as yours. So it wont solve the performance issue. One way to do this will be to use a javascript function to append the indices of only the selectedItem to a hiddenfield on its onClientClick event and then to parse the hidden field value in your code behind to get the Selected item indices.
If you get another good reliable way of doing it please post it here so that everyone can learn
Thanks
Last edited by Aneesh_Argent; Feb 17th, 2009 at 1:05 am.
Reputation Points: 16
Solved Threads: 18
Junior Poster
Aneesh_Argent is offline Offline
104 posts
since Dec 2008
Feb 17th, 2009
0

Re: Speedup CheckBoxList search

I got this solution too but for some reasons I preferred server side, yes Java Script would be better, Thank you Aneesh_Argent so much
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: control hierarchy
Next Thread in ASP.NET Forum Timeline: not sure of codes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC