代碼很簡單
C#
<%@ Page Language=
<!DOCTYPE html PUBLIC
<script runat=
// 計算數據
ICollection CreateDataSource()
{
System
System
dt
dt
dt
dt
dt
dt
for (int i =
{
System
dr = dt
dr[
dr[
dr[
dr[
dr[
dr[
dt
}
System
return dv;
}
protected void Page_Load(object sender
{
if (!IsPostBack)
{
GridView
GridView
GridView
}
}
protected void Button
{
Ret
foreach (GridViewRow gvr in GridView
{
CheckBox ch = (CheckBox)gvr
if (ch
{
Ret
}
}
}
protected void Button
{
Ret
foreach (GridViewRow gvr in GridView
{
CheckBox ch = (CheckBox)gvr
if (ch
{
Ret
}
}
}
protected void CheckAll(object sender
{
CheckBox cbx = (CheckBox)sender;
foreach (GridViewRow gvr in GridView
{
CheckBox ch = (CheckBox)gvr
ch
}
}
</script>
<html xmlns=
<head>
<title>GridView 實現服務器端和客戶端全選的兩種方法</title>
<script type=
//<![CDATA[
function CheckAll(oCheckbox)
{
var GridView
for(i =
{
GridView
}
}
//]]>
</script>
</head>
<body>
<form id=
<table >
<tr valign=
<td>
<asp:GridView ID=
GridLines=
<HeaderStyle BackColor=
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID=
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID=
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField=
<asp:BoundField DataField=
<asp:BoundField DataField=
<asp:BoundField DataField=
<asp:BoundField DataField=
</Columns>
</asp:GridView>
<asp:Button ID=
</td>
<td align=
<asp:GridView ID=
GridLines=
<HeaderStyle BackColor=
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input id=
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID=
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField=
<asp:BoundField DataField=
<asp:BoundField DataField=
<asp:BoundField DataField=
<asp:BoundField DataField=
</Columns>
</asp:GridView>
<asp:Button ID=
</td>
</tr>
<tr valign=
<td>
<asp:Literal ID=
</td>
<td align=
<asp:Literal ID=
</td>
</tr>
</table>
</form>
</body>
</html>
From:http://tw.wingwit.com/Article/program/net/201311/13455.html