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,如需转载请自行联系原作者
相关文章
|
8月前
|
机器学习/深度学习 人工智能 算法
探索软件测试的新时代:AI与自动化的融合
【6月更文挑战第9天】本文将探讨软件测试领域内的最新发展趋势,特别是人工智能(AI)和自动化技术的融合如何重新定义了软件测试的实践。我们将分析这些技术如何提高测试效率、准确性和可靠性,以及它们对测试工程师角色的影响。
|
9月前
|
Ubuntu Linux
Linux(22) Linux设置网络优先级顺序
Linux(22) Linux设置网络优先级顺序
925 0
|
NoSQL Java Redis
SpringBoot中如何实现限流,这种方式才叫优雅!
SpringBoot中如何实现限流,这种方式才叫优雅!
339 0
|
SQL 监控 关系型数据库
|
XML 存储 Ubuntu
RK3568开发笔记(五):在虚拟机上使用SDK编译制作uboot、kernel和ubuntu镜像
buildroot虽然灵活,但是基于实际情况,本身是侧重驱动和应用定制开发的只定制一次文件系统投入有点多,还不如直接ubunt自己交叉编译依赖库,做一些库的移植裁剪。   于是本篇就使用ubuntu系统了,至于其他库自己下源码在宿主机交叉编译号后,再拷贝过去或者直接在板子上编译也行(只是会比较慢),但是意义不大,因为开发过程肯定是用宿主机,不然核心板编译太慢,在编译上会花费不少可以省去的时间。
RK3568开发笔记(五):在虚拟机上使用SDK编译制作uboot、kernel和ubuntu镜像
|
缓存 算法 NoSQL
十分钟搞懂Java限流及常见方案
十分钟搞懂Java限流及常见方案
|
关系型数据库 MySQL 索引
MySQL next-key lock 加锁范围总结
三篇文章分别通过实际操作,介绍了主键、非主键唯一索引、普通索引、普通字段四个方面介绍了加锁的范围。 本篇文章再做一个总结。
775 0
|
7月前
|
数据采集 搜索推荐 JavaScript
禁止搜索
【7月更文挑战第9天】
118 1
|
9月前
|
消息中间件 Kafka
Kafka【部署 03】Zookeeper与Kafka自动部署脚本
【4月更文挑战第11天】Kafka【部署 03】Zookeeper与Kafka自动部署脚本
135 8

热门文章

最新文章