looping through checkboxes and inserting checkbox values to DB
- by user1150440
ASPX Page:
<asp:ListView ID="lvSubjects" runat="server" >
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<asp:CheckBox ID="cbRegularSubjects" Text=<%# Eval("SubjectName") %> runat="server" />
</ItemTemplate>
<AlternatingItemTemplate>
<asp:CheckBox ID="cbRegularSubjects" Text=<%# Eval("SubjectName") %> runat="server" />
</AlternatingItemTemplate>
</asp:ListView>
Code Behind:
For Each ctrl As Control In Page.Controls
If TypeOf ctrl Is CheckBox AndAlso CType(ctrl, CheckBox).Checked Then
'**Here I want to get the text of the check box and insert into the DB**
End If
Next
Where am i going wrong??i do not get any error...but this code is not working for me.