Find selected items in asp:checkboxlist
Thursday 10 September 2009
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:
-
<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:
-
For i = 0 To chk1.Items.Count - 1
-
If chkExpert.Items(i).Selected Then
-
Dim strSelectedValue1 As String = chk1.Items(i).Value
-
-
'You could not insert this into your database as you want
-
End If
-
Next
|
(2)
|
|
|