我究竟做错了什么?我有一个 CheckBoxList,我想一个一个地处理每个元素。我在“cbl.Items.Count”行收到错误提示该元素未使用“new”初始化。非常感谢你!
CheckBoxList cbl = (CheckBoxList)FindControl("CBL_categ");
for (int i = 0; i < cbl.Items.Count; i++)
{
if (cbl.Items[i].Selected)
catn = cbl.Items[i].Value;
}
编辑:
<asp:Content ID="Content4" runat="server"
contentplaceholderid="ContentPlaceHolder3">
<asp:Label ID="statusLabel" runat="server" Text=""> </asp:Label>
<asp:GridView ID="GridView1" AutoGenerateColumns="False" runat="server"
DataSourceID="SqlDataSource1" Visible="False" >
....
</asp:GridView>
<br />
Categories:<asp:CheckBoxList ID="CBL_categ" runat="server" DataTextField="name" DataValueField="name">
</asp:CheckBoxList>
</asp:Content>