XP 风格的可拖动列、排序的DataGrid的例子

XP 风格的可拖动列、排序的DataGrid的例子

作者:孟宪会 出自:【孟宪会之精彩世界】 发布日期:2003年12月19日 11点58分19秒


本文介绍XP 风格的可拖动列、排序的DataGrid的例子, 请查看

要想使用本源代码,请先下载如下文件:

  • downarrow.gif
  • sortBlank.gif
  • sortUp.gif
  • sortDown.gif
  • uparrow.gif
  • xpTable.css
  • xpTable.htc

源代码如下:【C#版本】

DragableXpStyleTable.aspx

1@ Page language="c#" Codebehind="DragableXpStyleTable.aspx.cs" AutoEventWireup="false" Inherits="eMeng.Exam.DragableXpStyleTable.DragableXpStyleTable" 

XP 风格的可拖动列、排序的DataGrid的例子。

DragableXpStyleTable.aspx.cs

using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.OleDb; namespace eMeng.Exam.DragableXpStyleTable { /// /// DragableXpStyleTable 的摘要说明。 /// XP风格的可拖动的DataGrid /// public class DragableXpStyleTable : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid xpTable; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 xpTable.Attributes.Add("altRowColor","oldlace"); xpTable.Attributes.Add("align","center"); string cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="; cnString += System.Web.HttpContext.Current.Server.MapPath("TestTable.mdb") OleDbConnection cn = new OleDbConnection(cnString); cn.Open(); cnString = "SELECT TOP 15 D.Title,D.CreateDate,S.Title AS SubTitle "; cnString += "FROM Document D,Subject S WHERE D.pid=S.id ORDER BY D.CreateDate DESC"; OleDbCommand cmd = new OleDbCommand(cnString,cn); xpTable.DataSource=cmd.ExecuteReader(CommandBehavior.CloseConnection); xpTable.DataBind(); cmd.Dispose(); cn.Close(); cn.Dispose(); cn = null; } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } }

Published At
Categories with Web编程
Tagged with
comments powered by Disqus