954,577 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Speedup CheckBoxList search

I want to speed ChechBoxList's getting the selected items, the normal approach is

foreach (ListItem li in checkListBox.Items)
{
if (li.Selected)
{
}
}

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 ??

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

That was abount the most stupid post I have sent

I think I will edit it out
wish there was a delete button

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

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

Aneesh_Argent
Junior Poster
104 posts since Dec 2008
Reputation Points: 16
Solved Threads: 18
 

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 :)

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You