实现方法有2种,客户端实现和服务端实现

客户端实现
(1)脚本
在DataGrid控件中添加CheckBox控件列,实现全选/全取消        <form id="Form1" method="post" runat="server">
在DataGrid控件中添加CheckBox控件列,实现全选/全取消            
<asp:DataGrid id="dgCheckBox" runat="server" AutoGenerateColumns="False" Width="472px">
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                
<Columns>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                    
<asp:TemplateColumn HeaderText="&lt;input type=checkbox id=CheckAll onclick='javascript:SelAll()'&gt; 全选/全取消">
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                        
<ItemTemplate>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                            
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                        
</ItemTemplate>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                    
</asp:TemplateColumn>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                    
<asp:BoundColumn DataField="LastName" HeaderText="LastName"></asp:BoundColumn>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                    
<asp:BoundColumn DataField="FirstName" HeaderText="FirstName"></asp:BoundColumn>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消                
</Columns>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消            
</asp:DataGrid>
在DataGrid控件中添加CheckBox控件列,实现全选/全取消        
</form>
(2)JavaScript
在DataGrid控件中添加CheckBox控件列,实现全选/全取消<script language="javascript">
在DataGrid控件中添加CheckBox控件列,实现全选/全取消        
function SelAll()
>
(3)代码
在DataGrid控件中添加CheckBox控件列,实现全选/全取消//定义公共变量,保存数据的行数
在DataGrid控件中添加CheckBox控件列,实现全选/全取消
public int RowCount;
在DataGrid控件中添加CheckBox控件列,实现全选/全取消        
private void Page_Load(object sender, System.EventArgs e)
}

服务端实现
这个方法就是出发事件回到服务端,捉行查看

相关文章: