0
ASPX页面:通过复选框循环和插入复选框值DB
<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>
代码背后:
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
我要去哪里错了?我没有得到任何错误。 ..但此代码不适合我。
列表视图是在面板内部和复选框是列表视图里面......我想点击一个按钮执行代码...我怎么去呢? – user1150440 2012-04-14 05:10:43
,我也在使用母版页。 – user1150440 2012-04-14 05:11:56
我得到'ItemRow'未定义。 – user1150440 2012-04-14 05:26:55