<%@ Page language="c#" Codebehind="DataGridCheckBoxJavaScript.aspx.cs" AutoEventWireup="false" Inherits="CommonFunction.数据绑定控件.DataGridCheckBoxJavaScript" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>DataGridCheckBoxJavaScript</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<asp:DataGrid id="dgCheckBox" runat="server" AutoGenerateColumns="False" Width="472px">
				<Columns>
					<asp:TemplateColumn HeaderText="&lt;input type=checkbox id=CheckAll onclick='javascript:SelAll()' title='全选/全取消'&gt;">
						<ItemTemplate>
							<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
						</ItemTemplate>
					</asp:TemplateColumn>
					<asp:BoundColumn DataField="LastName" HeaderText="LastName"></asp:BoundColumn>
					<asp:BoundColumn DataField="FirstName" HeaderText="FirstName"></asp:BoundColumn>
				</Columns>
			</asp:DataGrid>
		</form>
		<script language="javascript">
		function SelAll()
		{
			var RowCnt=<%=RowCount%>;
			var IsChk;
			IsChk = document.all.CheckAll.checked;
			for(j= 0;j<RowCnt+1;j ++ )
			{
				if(typeof(document.all.dgCheckBox.rows(j).cells(0).children(0)) == "object")
				{
					document.all.dgCheckBox.rows(j).cells(0).children(0).checked = IsChk;
			
				}
			}

		}
		</script>
	</body>
</HTML>
