DataGrid 完全攻略之三(实现删除全选或者全不选)

简介:

前台代码:html
<% @ Page language="c#" Codebehind="SelAndDropAll.aspx.cs" AutoEventWireup="false" Inherits="MsDataGrid.SelAndDropAll"  %>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"  >
< HTML >
    
< HEAD >
        
< title > DataGrid使用举例 </ title >
        
< meta  name ="GENERATOR"  Content ="Microsoft Visual Studio 7.0" >
        
< 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" >
            
< FONT  face ="宋体" >
                
< asp:DataGrid  id ="dgShow"  style ="Z-INDEX: 101; LEFT: 31px; POSITION: absolute; TOP: 93px"  runat ="server"  Width ="842px"  Height ="172px"  BorderColor ="Tan"  BorderWidth ="1px"  BackColor ="LightGoldenrodYellow"  CellPadding ="2"  GridLines ="None"  ForeColor ="Black"  PageSize ="1"  AutoGenerateColumns ="False" >
                    
< SelectedItemStyle  ForeColor ="GhostWhite"  BackColor ="DarkSlateBlue" ></ SelectedItemStyle >
                    
< AlternatingItemStyle  BackColor ="PaleGoldenrod" ></ AlternatingItemStyle >
                    
< HeaderStyle  Font-Bold ="True"  BackColor ="Tan" ></ HeaderStyle >
                    
< FooterStyle  BackColor ="Tan" ></ FooterStyle >
                    
< Columns >
                        
< asp:BoundColumn  DataField ="StudentID"  ReadOnly ="True"  HeaderText ="学生ID" ></ asp:BoundColumn >
                        
< asp:BoundColumn  DataField ="StudentName"  HeaderText ="学生姓名" ></ asp:BoundColumn >
                        
< asp:BoundColumn  DataField ="StudentPass"  HeaderText ="密码" ></ asp:BoundColumn >
                        
< asp:BoundColumn  DataField ="Sex"  HeaderText ="性别" ></ asp:BoundColumn >
                        
< asp:BoundColumn  DataField ="Birthday"  HeaderText ="生日"  DataFormatString ="{0:yyyy-M-d}" ></ asp:BoundColumn >
                        
< asp:BoundColumn  DataField ="Email"  HeaderText ="邮件地址" ></ asp:BoundColumn >
                        
< asp:EditCommandColumn  ButtonType ="LinkButton"  UpdateText ="更新"  HeaderText ="操作"  CancelText ="取消"  EditText ="编辑" ></ asp:EditCommandColumn >
                        
< asp:ButtonColumn  Text ="删除"  HeaderText ="删除"  CommandName ="Delete" ></ asp:ButtonColumn >
                        
< asp:TemplateColumn  HeaderText ="选择" >
                            
< HeaderTemplate >
                                
< asp:CheckBox  id ="cbAll"  runat ="server"  OnCheckedChanged ="CheckAll"  Text ="全选"  AutoPostBack ="True" ></ asp:CheckBox >
                            
</ HeaderTemplate >
                            
< ItemTemplate >
                                
< asp:CheckBox  id ="cbSelect"  runat ="server"  AutoPostBack ="True" ></ asp:CheckBox >
                            
</ ItemTemplate >
                        
</ asp:TemplateColumn >
                    
</ Columns >
                    
< PagerStyle  HorizontalAlign ="Center"  ForeColor ="DarkSlateBlue"  BackColor ="PaleGoldenrod" ></ PagerStyle >
                
</ asp:DataGrid >
                
< asp:Button  id ="btnDelete"  style ="Z-INDEX: 102; LEFT: 34px; POSITION: absolute; TOP: 47px"  runat ="server"  Text ="删除" ></ asp:Button ></ FONT >
        
</ form >
    
</ body >
</ HTML >

后台代码:cs
<% @ Page language = " c# "  Codebehind = " SelAndDropAll.aspx.cs "  AutoEventWireup = " false "  Inherits = " MsDataGrid.SelAndDropAll "   %>
<! DOCTYPE HTML PUBLIC  " -//W3C//DTD HTML 4.0 Transitional//EN "   >
< HTML >
    
< HEAD >
        
< title > DataGrid使用举例 </ title >
        
< meta name = " GENERATOR "  Content = " Microsoft Visual Studio 7.0 " >
        
< 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 " >
            
< FONT face = " 宋体 " >
                
< asp:DataGrid id = " dgShow "  style = " Z-INDEX: 101; LEFT: 31px; POSITION: absolute; TOP: 93px "  runat = " server "  Width = " 842px "  Height = " 172px "  BorderColor = " Tan "  BorderWidth = " 1px "  BackColor = " LightGoldenrodYellow "  CellPadding = " 2 "  GridLines = " None "  ForeColor = " Black "  PageSize = " 1 "  AutoGenerateColumns = " False " >
                    
< SelectedItemStyle ForeColor = " GhostWhite "  BackColor = " DarkSlateBlue " ></ SelectedItemStyle >
                    
< AlternatingItemStyle BackColor = " PaleGoldenrod " ></ AlternatingItemStyle >
                    
< HeaderStyle Font - Bold = " True "  BackColor = " Tan " ></ HeaderStyle >
                    
< FooterStyle BackColor = " Tan " ></ FooterStyle >
                    
< Columns >
                        
< asp:BoundColumn DataField = " StudentID "  ReadOnly = " True "  HeaderText = " 学生ID " ></ asp:BoundColumn >
                        
< asp:BoundColumn DataField = " StudentName "  HeaderText = " 学生姓名 " ></ asp:BoundColumn >
                        
< asp:BoundColumn DataField = " StudentPass "  HeaderText = " 密码 " ></ asp:BoundColumn >
                        
< asp:BoundColumn DataField = " Sex "  HeaderText = " 性别 " ></ asp:BoundColumn >
                        
< asp:BoundColumn DataField = " Birthday "  HeaderText = " 生日 "  DataFormatString = " {0:yyyy-M-d} " ></ asp:BoundColumn >
                        
< asp:BoundColumn DataField = " Email "  HeaderText = " 邮件地址 " ></ asp:BoundColumn >
                        
< asp:EditCommandColumn ButtonType = " LinkButton "  UpdateText = " 更新 "  HeaderText = " 操作 "  CancelText = " 取消 "  EditText = " 编辑 " ></ asp:EditCommandColumn >
                        
< asp:ButtonColumn Text = " 删除 "  HeaderText = " 删除 "  CommandName = " Delete " ></ asp:ButtonColumn >
                        
< asp:TemplateColumn HeaderText = " 选择 " >
                            
< HeaderTemplate >
                                
< asp:CheckBox id = " cbAll "  runat = " server "  OnCheckedChanged = " CheckAll "  Text = " 全选 "  AutoPostBack = " True " ></ asp:CheckBox >
                            
</ HeaderTemplate >
                            
< ItemTemplate >
                                
< asp:CheckBox id = " cbSelect "  runat = " server "  AutoPostBack = " True " ></ asp:CheckBox >
                            
</ ItemTemplate >
                        
</ asp:TemplateColumn >
                    
</ Columns >
                    
< PagerStyle HorizontalAlign = " Center "  ForeColor = " DarkSlateBlue "  BackColor = " PaleGoldenrod " ></ PagerStyle >
                
</ asp:DataGrid >
                
< asp:Button id = " btnDelete "  style = " Z-INDEX: 102; LEFT: 34px; POSITION: absolute; TOP: 47px "  runat = " server "  Text = " 删除 " ></ asp:Button ></ FONT >
        
</ form >
    
</ body >
</ HTML >



本文转自高海东博客园博客,原文链接:http://www.cnblogs.com/ghd258/archive/2005/10/12/253185.html,如需转载请自行联系原作者
相关文章
|
4月前
|
前端开发 数据安全/隐私保护
【前端web入门第二天】02 表单-input标签-单选框-多选框
本文介绍了HTML中`&lt;input&gt;`标签的基本使用方法及其应用场景,如登录、注册页面和搜索区域。通过设置`type`属性,可以实现文本框、密码框、单选框、多选框及文件上传等功能。此外,还详细说明了占位文本的使用、单选框的常用属性及多选框的默认选中状态,并提供了示例代码与效果展示。
121 7
|
8月前
《vue3实战》运用radio单选按钮或Checkbox复选框实现单选多选的试卷制作
《vue3实战》运用radio单选按钮或Checkbox复选框实现单选多选的试卷制作
|
JavaScript 前端开发
jquery的数据增删改查(全选,反选,全不选,批量删除,添加信息)
jquery的数据增删改查(全选,反选,全不选,批量删除,添加信息)
137 0
|
JavaScript PHP 数据库
layui框架实战案例(18):保存草稿和单选radio复选框checkbox无focus属性快速聚焦跳转的解决方案
layui框架实战案例(18):保存草稿和单选radio复选框checkbox无focus属性快速聚焦跳转的解决方案
275 0
|
存储 关系型数据库 MySQL
Easyui datagrid combobox输入框下拉(取消)选值和编辑已选值处理
Easyui datagrid combobox输入框下拉(取消)选值和编辑已选值处理
429 0
|
前端开发
bootstrap 组件 警告框 徽章 面包屑导航 按钮 按钮组 学习总结
bootstrap 组件 警告框 徽章 面包屑导航 按钮 按钮组 学习总结
|
JavaScript 前端开发
【JavaScript】案例 :复选框全选-全不选&省市二级联动以及课外扩展
本期主要介绍案例 :复选框全选-全不选&省市二级联动以及课外扩展
118 0
【JavaScript】案例 :复选框全选-全不选&省市二级联动以及课外扩展
手把手教你实现GridView中Checkbox全选
手把手教你实现GridView中Checkbox全选
手把手教你实现GridView中Checkbox全选
|
JavaScript
freemaker页面复选框全选与反选
freemaker页面复选框全选与反选

热门文章

最新文章