这几天做了个DataGrid扩展控件,如题。但是由于工作忙,打算过一段时间对它完善,放到这里备忘,也给大家看看,提些意见,给一些启发,asp.net我也是刚用不久,QQ:8613441
[WebForm1.aspx]
<%
...
@ Register TagPrefix="cc1" Namespace="XLCtrlLib" Assembly="XLCtrlLib"
%>
<% ... @ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="TestXDataGrid.WebForm1" %>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< title > WebForm1 </ title >
< meta content ="Microsoft Visual Studio .NET 7.1" name ="GENERATOR" >
< meta content ="C#" name ="CODE_LANGUAGE" >
< meta content ="JavaScript" name ="vs_defaultClientScript" >
< meta content ="http://schemas.microsoft.com/intellisense/ie5" name ="vs_targetSchema" >
</ HEAD >
< body MS_POSITIONING ="GridLayout" >
< form id ="Form1" method ="post" runat ="server" >
< FONT face ="宋体" >
< cc1:XDataGrid id ="XDataGrid1" style ="Z-INDEX: 101; LEFT: 312px; POSITION: absolute; TOP: 176px"
runat ="server" Width ="80px" Height ="40px" ImagePath ="Common/Images/Office2003/ToolBar/" ></ cc1:XDataGrid >
< cc1:XDataGrid id ="XDataGrid2" style ="Z-INDEX: 102; LEFT: 344px; POSITION: absolute; TOP: 312px"
runat ="server" Width ="104px" Height ="24px" ImagePath ="Common/Images/Office2003/ToolBar/" ></ cc1:XDataGrid ></ FONT ></ form >
</ body >
</ HTML >
<% ... @ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="TestXDataGrid.WebForm1" %>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< title > WebForm1 </ title >
< meta content ="Microsoft Visual Studio .NET 7.1" name ="GENERATOR" >
< meta content ="C#" name ="CODE_LANGUAGE" >
< meta content ="JavaScript" name ="vs_defaultClientScript" >
< meta content ="http://schemas.microsoft.com/intellisense/ie5" name ="vs_targetSchema" >
</ HEAD >
< body MS_POSITIONING ="GridLayout" >
< form id ="Form1" method ="post" runat ="server" >
< FONT face ="宋体" >
< cc1:XDataGrid id ="XDataGrid1" style ="Z-INDEX: 101; LEFT: 312px; POSITION: absolute; TOP: 176px"
runat ="server" Width ="80px" Height ="40px" ImagePath ="Common/Images/Office2003/ToolBar/" ></ cc1:XDataGrid >
< cc1:XDataGrid id ="XDataGrid2" style ="Z-INDEX: 102; LEFT: 344px; POSITION: absolute; TOP: 312px"
runat ="server" Width ="104px" Height ="24px" ImagePath ="Common/Images/Office2003/ToolBar/" ></ cc1:XDataGrid ></ FONT ></ form >
</ body >
</ HTML >
[WebForm1.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;
namespace TestXDataGrid
... {
/**//// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
...{
protected XLCtrlLib.XDataGrid XDataGrid2;
protected XLCtrlLib.XDataGrid XDataGrid1;
private void Page_Load(object sender, System.EventArgs e)
...{
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
...{
this.XDataGrid1.SqlQuery = "SELECT * FROM s_dict";
this.XDataGrid1.xPageSize = 8;
this.XDataGrid1.AddColumn("RID", "流水号", 100, 0);
this.XDataGrid1.AddColumn("IKEY", "键", 100, 0);
this.XDataGrid1.AddColumn("IVALUE", "值", 200, 0);
this.XDataGrid2.SqlQuery = "SELECT * FROM s_dict";
this.XDataGrid2.xPageSize = 5;
this.XDataGrid2.AddColumn("RID", "流水号", 100, 0);
this.XDataGrid2.AddColumn("IKEY", "键", 100, 0);
this.XDataGrid2.AddColumn("IVALUE", "值", 200, 0);
}
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
...{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
...{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
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;
namespace TestXDataGrid
... {
/**//// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
...{
protected XLCtrlLib.XDataGrid XDataGrid2;
protected XLCtrlLib.XDataGrid XDataGrid1;
private void Page_Load(object sender, System.EventArgs e)
...{
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
...{
this.XDataGrid1.SqlQuery = "SELECT * FROM s_dict";
this.XDataGrid1.xPageSize = 8;
this.XDataGrid1.AddColumn("RID", "流水号", 100, 0);
this.XDataGrid1.AddColumn("IKEY", "键", 100, 0);
this.XDataGrid1.AddColumn("IVALUE", "值", 200, 0);
this.XDataGrid2.SqlQuery = "SELECT * FROM s_dict";
this.XDataGrid2.xPageSize = 5;
this.XDataGrid2.AddColumn("RID", "流水号", 100, 0);
this.XDataGrid2.AddColumn("IKEY", "键", 100, 0);
this.XDataGrid2.AddColumn("IVALUE", "值", 200, 0);
}
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
...{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
...{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}