1.html
<
HTML
>
< HEAD >
< title > DragDataGrid </ title >
< meta name ="GENERATOR" Content ="Microsoft Visual Studio .NET 7.1" >
< meta name ="CODE_LANGUAGE" Content ="C#" >
< meta name ="vs_defaultClientScript" content ="JavaScript" >
< meta name ="vs_targetSchema" content ="http://schemas.microsoft.com/intellisense/ie5" >
< LINK href ="xpTable.css" type ="text/css" rel ="stylesheet" >
</ HEAD >
< body ms_positioning ="GridLayout" >
< form id ="Form1" method ="post" runat ="server" >
< asp:DataGrid id ="DataGrid1" runat ="server" Font-Size ="9pt" CellPadding ="4" style ="BEHAVIOR:url(draggrid.htc)"
BorderColor ="#CC9966" BorderStyle ="None" BorderWidth ="1px" BackColor ="White" >
< SelectedItemStyle Font-Bold ="True" ForeColor ="#663399" BackColor ="#FFCC66" ></ SelectedItemStyle >
< ItemStyle ForeColor ="#330099" BackColor ="White" ></ ItemStyle >
< HeaderStyle Font-Bold ="True" ForeColor ="#FFFFCC" BackColor ="#990000" ></ HeaderStyle >
< FooterStyle ForeColor ="#330099" BackColor ="#FFFFCC" ></ FooterStyle >
< PagerStyle HorizontalAlign ="Center" ForeColor ="#330099" BackColor ="#FFFFCC" ></ PagerStyle >
</ asp:DataGrid >
</ form >
</ body >
</ HTML >
2.cs
< HEAD >
< title > DragDataGrid </ title >
< meta name ="GENERATOR" Content ="Microsoft Visual Studio .NET 7.1" >
< meta name ="CODE_LANGUAGE" Content ="C#" >
< meta name ="vs_defaultClientScript" content ="JavaScript" >
< meta name ="vs_targetSchema" content ="http://schemas.microsoft.com/intellisense/ie5" >
< LINK href ="xpTable.css" type ="text/css" rel ="stylesheet" >
</ HEAD >
< body ms_positioning ="GridLayout" >
< form id ="Form1" method ="post" runat ="server" >
< asp:DataGrid id ="DataGrid1" runat ="server" Font-Size ="9pt" CellPadding ="4" style ="BEHAVIOR:url(draggrid.htc)"
BorderColor ="#CC9966" BorderStyle ="None" BorderWidth ="1px" BackColor ="White" >
< SelectedItemStyle Font-Bold ="True" ForeColor ="#663399" BackColor ="#FFCC66" ></ SelectedItemStyle >
< ItemStyle ForeColor ="#330099" BackColor ="White" ></ ItemStyle >
< HeaderStyle Font-Bold ="True" ForeColor ="#FFFFCC" BackColor ="#990000" ></ HeaderStyle >
< FooterStyle ForeColor ="#330099" BackColor ="#FFFFCC" ></ FooterStyle >
< PagerStyle HorizontalAlign ="Center" ForeColor ="#330099" BackColor ="#FFFFCC" ></ PagerStyle >
</ asp:DataGrid >
</ form >
</ body >
</ HTML >
public
class
DragDataGrid : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private string constring="";
private void Page_Load(object sender, System.EventArgs e)
{
string sql="select * from testgrid";
DataSet ds=GetDataSet(sql);
this.DataGrid1.DataSource=ds;
this.DataGrid1.DataBind();
}
GetDataSet#region GetDataSet
private DataSet GetDataSet(string sql)
{
constring=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlDataAdapter sda =new SqlDataAdapter(sql,constring);
DataSet ds=new DataSet();
sda.Fill(ds);
return ds;
}
#endregion
Web Form Designer generated code#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
3.源代码下载
/Files/singlepine/draggridcol.rar
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private string constring="";
private void Page_Load(object sender, System.EventArgs e)
{
string sql="select * from testgrid";
DataSet ds=GetDataSet(sql);
this.DataGrid1.DataSource=ds;
this.DataGrid1.DataBind();
}
GetDataSet#region GetDataSet
private DataSet GetDataSet(string sql)
{
constring=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlDataAdapter sda =new SqlDataAdapter(sql,constring);
DataSet ds=new DataSet();
sda.Fill(ds);
return ds;
}
#endregion
Web Form Designer generated code#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}