<asp:Repeater ID="rptOut" runat="server" onitemdatabound="rptOut_ItemDataBound"
onitemcommand="rptOut_ItemCommand">
<ItemTemplate>
<div class="parentMenu" runat="server">
<asp:Label ID="Label1" Visible="false" runat="server" Text='<%# Eval("MenuID") %>'></asp:Label>
<h4>
<asp:CheckBox ID="chk_all" AutoPostBack="true" OnCheckedChanged="chk_all_CheckedChanged" runat="server" />
<%-- <asp:Button ID="chkAll" CommandName="selectAll" runat="server" Text="全选" />
<asp:Button ID="chkNull" CommandName="selectNull" runat="server" Text="反选" />--%>
<%# Eval("Title") %>
</h4>
<asp:Repeater ID="rptIn" runat="server">
<ItemTemplate>
<span><asp:CheckBox name="chk_list" ID="chk_list" Text='<%# Eval("Title")%>' runat="server" /></span>
<asp:Label Name="MemuID" ID="MenuID" Text='<%# Eval("MenuID")%>' runat="server" Visible ="false" />
</ItemTemplate>
</asp:Repeater>
<asp:Repeater ID="rptHide" runat="server">
<ItemTemplate>
<asp:Label Name="MemuID" ID="lblMenuID" Text='<%# Eval("MenuID")%>' runat="server" Visible ="false" />
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
发一点点源码吧,想给你贴代码不知道如何下手。是一个Table吗?
<input id="SelectAll" type="checkbox" />
<div id="CheckBoxList">
<input id="Checkbox1" type="checkbox" />
<input id="Checkbox2" type="checkbox" />
<input id="Checkbox3" type="checkbox" />
<input id="Checkbox4" type="checkbox" />
<input id="Checkbox5" type="checkbox" />
<input id="Checkbox6" type="checkbox" />
<input id="Checkbox7" type="checkbox" />
<input id="Checkbox8" type="checkbox" />
</div>
document.getElementById("SelectAll").onclick = function () {
var CheckBoxList = document.getElementById("CheckBoxList").getElementsByTagName("INPUT"), i = 0;
for (; i < CheckBoxList.length; i++) {
if (CheckBoxList[i].type == "checkbox")
CheckBoxList[i].checked = this.checked;
}
}
这样需要在前台写一些JS来控制。可以用一些树形JS控件实现,比如: