博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DataGrid 完全攻略之三(实现删除全选或者全不选)
阅读量:6096 次
发布时间:2019-06-20

本文共 5663 字,大约阅读时间需要 18 分钟。

前台代码: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,如需转载请自行联系原作者
你可能感兴趣的文章
NumPy Cookbook 带注释源码 六、NumPy 特殊数组与通用函数
查看>>
好友辞职的一些想法
查看>>
JS之原生JS获取表单得所有值
查看>>
JDBC Driver接口连接数据库,实际开发基本不用
查看>>
Golang 中的并发限制与超时控制
查看>>
【Tip】如何让引用的dll随附的xml注释文档、pdb调试库等文件不出现在项目输出目录中...
查看>>
数据填报修改时如何增加操作人员信息
查看>>
WPF InkCanvas 毛笔效果
查看>>
BugHD 新功能-更灵活的崩溃收集、更精准的崩溃定位
查看>>
lua 调用 dll 的简单demo
查看>>
Electron 5.0.0 发布
查看>>
基于Django实现 RESTful API 之RestFramework框架1
查看>>
下一步瞄准室内,u-blox厘米级高精定位为自动驾驶铺路
查看>>
Kodi 基金会加入 Linux 基金会,帮助发展开源运动
查看>>
Linux下用户的创建与删除
查看>>
python3中的进程
查看>>
[LeetCode]1-bit and 2-bit Characters 1位和2位字符
查看>>
[网络基础] Web请求与响应
查看>>
锋利 RAM 合集
查看>>
Python Vs R:数据科学家的永恒问题
查看>>