<script language="javascript">
function CheckAllCheckboxes()
{
var d=document.getElementById("GridView1").getElementsByTagName("input");
for (var i=0;i<d.length;i++)
{
if(d[i].type=="checkbox")
{
d[i].checked=!d[i].checked;
}
}
}
</script>
<asp:TemplateField HeaderText="全选<input type=checkbox id='ChAll' onclick='CheckAllCheckboxes()'/>">
<ItemTemplate>
<asp:CheckBox runat="server" ID="CheckBox1" />
</ItemTemplate>
function CheckAll(objControl)
{
var element;
var i = 0;
var isCheck;
for(var i=0;i<document.getElementById(objControl).getElementsByTagName("input").length;i++)
{
var dd=objControl+"_"+i;
document.getElementById(dd).checked = !document.getElementById(dd).checked;
}
}