I have a check-box-List which I bind to a master dataTable(DTA)… I have another dataTable (DTB) which has the values that needs to checked in the check-box-List… So I loop through all items in the check-box-list to see if it exists in the DTB and set checked = true for those items that exists.
Now I want to show the checked items first in the Check-box-list box and the unchecked items below that.
Is there any way I can do it… A similar solution for List-Box could also be helpful. A Javascript hint is welcome too.
Thanks
– Raja
Best Answer
if you want to sort the check-box-list on the server side, you can first add the items from DTB to the check-box-list and set their Selected value to true, then add the others form DTA and for each item in DTA make sure it's not already in the list of items.
when inserting the two lists make sure they are sorted according to a secondary sort criteria if you need one.
if you don't need the sorting to take place on the server side you can use jquery to do that quite easily.
you need to get the
check_box_list_client_id
from the server, you can do that using$('#<%= CheckBoxList1.ClientID %>')
jquery selector.thats it, hope it got you where you needed.