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

简介:

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

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



本文转自高海东博客园博客,原文链接:http://www.cnblogs.com/ghd258/archive/2005/10/12/253185.html,如需转载请自行联系原作者
相关文章
|
2月前
《vue3实战》运用radio单选按钮或Checkbox复选框实现单选多选的试卷制作
《vue3实战》运用radio单选按钮或Checkbox复选框实现单选多选的试卷制作
|
5月前
|
C++
C++ Qt开发:CheckBox多选框组件
Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍`CheckBox`单行输入框组件的常用方法及灵活运用。`QCheckBox` 是 Qt 中用于实现复选框的组件,它提供了丰富的功能和灵活性。与之前文章中的`RadioButton`组件不同,`CheckBox`组件支持多项选择以及三态支持,即可以是选中、未选中或半选中的状态。
46 0
C++ Qt开发:CheckBox多选框组件
|
6月前
《QT从基础到进阶·二十四》按钮组QButtonGroup,单选框QRadioButton和多选框QCheckBox
《QT从基础到进阶·二十四》按钮组QButtonGroup,单选框QRadioButton和多选框QCheckBox
86 0
|
10月前
|
JavaScript 前端开发
jquery的数据增删改查(全选,反选,全不选,批量删除,添加信息)
jquery的数据增删改查(全选,反选,全不选,批量删除,添加信息)
83 0
|
10月前
|
JavaScript PHP 数据库
layui框架实战案例(18):保存草稿和单选radio复选框checkbox无focus属性快速聚焦跳转的解决方案
layui框架实战案例(18):保存草稿和单选radio复选框checkbox无focus属性快速聚焦跳转的解决方案
184 0
|
12月前
零基础VB教程039期:如何使用单选按钮optionbutton以及多选框checkbox
零基础VB教程039期:如何使用单选按钮optionbutton以及多选框checkbox
212 0
|
存储 关系型数据库 MySQL
Easyui datagrid combobox输入框下拉(取消)选值和编辑已选值处理
Easyui datagrid combobox输入框下拉(取消)选值和编辑已选值处理
349 0
elementui里checkbox全选操作
elementui里checkbox全选操作
220 0
手把手教你实现GridView中Checkbox全选
手把手教你实现GridView中Checkbox全选
手把手教你实现GridView中Checkbox全选