檢查全部取消複選框中的GridView使用jQuery檢查全部取消複選框中的GridView使用jQuery
查看更多:C#ASP.NET jQuery的
在這裏所有的複選框不工作在標題複選框一個單一的點擊
<script type="text/javascript" language="javascript">
function CheckAll(Checkbox) {
var GridView1 = document.getElementById("<%=GridView1.ClientID %>");
for (i = 1; i < GridView1.rows.length; i++) {
GridView1.rows[i].cells[3].getElementsByTagName("INPUT")[0].checked =Checkbox.checked;
}}
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="624px" CssClass="grid"
AllowPaging="True" AllowSorting="True" BackColor="White" OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" PageSize = "5"
OnRowUpdating="GridView1_RowUpdating" DataKeyNames="id">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="chkHeader" runat="server" onclick="CheckAll(this)"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkchild" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="updatedby" HeaderText="updatedby" SortExpression="updatedby" />
<asp:BoundField DataField="username" HeaderText="username" SortExpression="username" />
<asp:BoundField DataField="password" HeaderText="password" SortExpression="password" />
<asp:BoundField DataField="mail" HeaderText="mail" SortExpression="mail" />
<asp:BoundField DataField="imagename" HeaderText="imagename" SortExpression="imagename" />
<asp:ImageField DataImageUrlField="uploadimage" HeaderText="uploadimage" ControlStyle-Width = "80" ControlStyle-Height = "100">
<ControlStyle Height="100px" Width="80px"></ControlStyle>
</asp:ImageField>
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>