求明白人帮看下
我想通过选中repeater控件中的checkbox来删除某一些行 但不管怎么选checked好像一直false
cs代码: CheckBox CheckBox1;
string idList = "";
for (int i = 0; i < Repeater1.Items.Count; i++) {
CheckBox1= (CheckBox)Repeater1.Items[i].FindControl("CheckBox1");
if (CheckBox1.Checked==true) {
Label lbId=(Label)Repeater1.Items[i].FindControl("Label1");
if (i < Repeater1.Items.Count - 1)
{
idList = idList.Trim() + lbId.Text.ToString() + ",";
}
else {
idList = idList.Trim() + lbId.Text.ToString();
}
}
bool b= infoMgr.DeleteList(idList);
repeater绑定代码
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate><table class="table_style"><tr style="background-color:#FAF9FF"><td>选择</td><td>编号</td><td>标题</td><td>类别</td><td>发布时间</td><td>操作</td></tr></HeaderTemplate>
<ItemTemplate><tr><td>
<asp:CheckBox ID="CheckBox1" runat="server" /><asp:Label ID="Label1" runat="server"
Text='<%#Eval("ID") %>'></asp:Label>
</td><td><%#Eval("ID") %></td><td><%#Eval("TITLE") %></td><td><%#Eval("SORT") %></td><td><%#Eval("DATE_CREATED") %></td><td>修改|详细</td></tr></ItemTemplate>
<AlternatingItemTemplate><tr style="background-color:#F9F9F9"><td><asp:CheckBox ID="CheckBox1" runat="server" /></td><td><%#Eval("ID") %></td><td><%#Eval("TITLE") %></td><td><%#Eval("SORT") %></td><td><%#Eval("DATE_CREATED") %></td><td>修改|详细</td></tr></AlternatingItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
------解决方案--------------------
在Page_Load里面用if(!IsPostback){绑定repeater控件}