1.html:
1 <asp:GridView runat="server" ID="gvAddBySR" AutoGenerateColumns="False" HorizontalAlign="Left" 2 Width="100%" EmptyDataText="<%$ Resources:GlobalResource, NoData%>"> 3 <Columns> 4 <asp:TemplateField HeaderStyle-Width="7%"> 5 <HeaderTemplate> 6 <input id="CheckAll" type="checkbox" onclick="selectAll(this);" /> 7 </HeaderTemplate> 8 <ItemTemplate> 9 <asp:CheckBox runat="server" ID="ck" class="ck" onclick="getCk(this);"/> 10 </ItemTemplate> 11 </asp:TemplateField>
2.js
1 function selectAll(obj) { 2 var idAll = obj; 3 Ced = idAll.checked; 4 UCed = idAll.form.elements; 5 var c = UCed.length; 6 for (i = 0; i < UCed.length; i++) { 7 if (UCed[i].type == "checkbox" && UCed[i] != idAll.id) { 8 if (UCed[i].checked != Ced) { 9 UCed[i].click(); 10 } 11 } 12 } 13 }
时间: 2024-10-05 18:22:41