<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm43.aspx.cs" Inherits="ASP.NETWebControlDaQuan.WebForm43" %>
<!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>
<script language="javascript" type="text/javascript">
//利用javascript实现复选框的全选功能
function allSelect() {
var v1 = document.getElementById("selectAll");
var v2 = document.getElementsByName("select");
for (var i = 0; i < v2.length; i++) {
v2[i].checked = v1.checked;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gv" runat="server" DataSourceID="studentDataSource" AllowPaging="true">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input type="checkbox" id="selectAll" onclick="allSelect()" />
</HeaderTemplate>
<ItemTemplate>
<input type="checkbox" name="select" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="studentDataSource"
runat="server" ConnectionString="server=(local);database=db_students;integrated
security=true" SelectCommand="select top 100 * from CwwTest">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>