Find selected items in asp:checkboxlist




Find selected items in asp:checkboxlist
If you have an asp:checkboxlist on your page and you binded your data to it, now you want to find which items are selected within that check box list, the below should help to demonstrate how this is done:
 
Let presume your asp:checkboxlist is like below:
  1. <asp:checkboxlist id="chk1" runat="server" datavaluefield="CatID" datatextfield="CatName" />  
Now to find which items are selected in the checkboxlist show above, use the below:

  1. For i = 0 To chk1.Items.Count - 1   
  2.         If chkExpert.Items(i).Selected Then  
  3.               Dim strSelectedValue1 As String = chk1.Items(i).Value   
  4.   
  5.               'You could not insert this into your database as you want   
  6.         End If  
  7. Next  


2 people like this article, click here to say you like this article too (2)
Send a link to this page via email Send a link to this page