推這篇囉: http://blog.xuite.net/juice0708/life/31239364
<script type="text/javascript">
function Check(oCheckbox)
{
var GridView1 = document.getElementById("<%=GridView1.ClientID %>");
for(i = 1;i < GridView1.rows.length; i++)
{
GridView1.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked = oCheckbox.checked;
}
}
</script>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="844px" AllowPaging="True" DataKeyNames="Item_ID"
OnPageIndexChanging ="GridView1_PageIndexChanging" OnRowCommand="GridView1_RowCommand" >
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" onclick="javascript:Check(this)" />
</HeaderTemplate>
</Columns>
</asp:GridView>
留言列表