日期:2014-05-17 浏览次数:20670 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <div> <table style="border-collapse: collapse;" border="1"> <tr> <th> </th> <th> 员工号 </th> <th> 员工姓名 </th> </tr> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <tr> <td> <asp:CheckBox ID="CB" runat="server" /> </td> <td> <asp:Literal ID="Literal1" runat="server" Text='<%#Eval("EmpID") %>'></asp:Literal> </td> <td> <%#Eval("EmpName") %> </td> </tr> </ItemTemplate> </asp:Repeater> </table> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> </div> </form> </body> </html>
------解决方案--------------------
RepeaterItem item = chksReg.NamingContainer as RepeaterItem; CheckBox checkBox = item.FindControl("chksAllRegion") as CheckBox; if (checkBox.Checked) { for (int i = 0; i < chksReg.Items.Count; i++) { if (!chksReg.Items[i].Selected) { checkBox.Checked = false; break; } } }
------解决方案--------------------
运行页面,然后你可以查看页面的源代码文件,看看那个checkbox的name属性,然后用这个name看行不行。
------解决方案--------------------
在它的属性有个返回的事件的吧
------解决方案--------------------
for (int i = 0; i < this.cklContext.Items.Count; i++)
{
if (this.cklContext.Items[i].Selected == true)
{
list += this.cklContext.SelectedItem.Value;
this.cklContext.Items[i].Selected = false;
}
}
------解决方案--------------------