前台代码: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 >
<! 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 >
<! 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,如需转载请自行联系原作者