全编辑WebGrid控件LrcGrid(5)—— 构造函数、变量和属性

80酷酷网    80kuku.com

  web|变量|函数|控件全编辑WebGrid控件LrcGrid(5)—— 构造函数、变量和属性

LrcGrid从System.Web.UI.WebControls.Table继承,实现INamingContainer接口

元数据属性和构造函数:元数据声明了控件的标签和默认属性,构造函数为控件一些属性指定了默认值.

[
ToolboxData("<{0}:LrcGrid runat=server></{0}:LrcGrid>"),
DefaultProperty("SelSql")
]
public class LrcGrid : System.Web.UI.WebControls.Table,INamingContainer
{

public LrcGrid() : base()
{
Font.Name = "verdana";
Font.Size = FontUnit.Point(8);
BackColor = Color.White;
ForeColor = Color.Black;
BorderStyle = BorderStyle.Outset;
BorderWidth = Unit.Parse("1px");
PagerStyle = PagerStyle.NextPrev;
CurrentPageIndex = 0;
ItemsPerPage = 15;
TotalPages = -1;
IsPager = true;
}
......

声明私有变量:

和分页相关的私有变量

#region 和分页有关的私有变量
// ***********************************************************************
private string CurrentPageText = "<b>第</b> {0} <b>页,共</b> {1}<b>页</b>";
private string NoPageSelectedText = "无选择页.";
private string QueryPageCommandText = "SELECT * FROM " +
"(SELECT TOP {0} * FROM " +
"(SELECT TOP {1} * FROM ({2}) AS t0 ORDER BY {3} {4}) AS t1 " +
"ORDER BY {3} {5}) AS t2 " +
"ORDER BY {3}";
private string QueryCountCommandText = "SELECT COUNT(*) FROM ({0}) AS t0";
// ***********************************************************************
#endregion


和属性有关的私有变量:

char[] chra = {','};
char[] chrb = {'|'};
//private DataSet _ds;
//private DataTable _dt;
private string tabN;
private string _priKey;
private string _editCol = "1";
private string _colsStr = "";
private string _colsStrCN = "";
private string _fkCol = "";
private bool _isSort = true;
private bool _isRowEdit;
private bool _isTabChg = true;
private bool _isDel;
private bool _isAdd;
private string _conn;
private Color _titColor;



控件属性,属性都有注释,不再细述:

/// <summary>
/// 外键指示
/// </summary>
[
Category("关键"),
Description("外键.格式:本表列名|外键列名|要显示的外键列名|外键表名,.....")
]
public string FkCol
{
get{return _fkCol;}
set{_fkCol = value;}
}
/// <summary>
/// 是否显示删除功能
/// </summary>
[
Category("关键"),
Description("是否显示删除功能")
]
public bool IsDel
{
get{return _isDel;}
set{_isDel = value;}
}
/// <summary>
/// 是否显示添加功能
/// </summary>
[
Category("关键"),
Description("是否显示添加功能")
]
public bool IsAdd
{
get{return _isAdd;}
set{_isAdd = value;}
}
/// <summary>
/// 公共属性:显示列名
/// </summary>
[
Category("关键"),
Description("显示列名")
]
public string ColsStrCN
{
get{return _colsStrCN;}
set{_colsStrCN = value;}
}
/// <summary>
/// 主表的表名
/// </summary>
[
Category("关键"),
Description("主表的表名")
]
public string TabN
{
get{return tabN;}
set{tabN = value;}
}
/// <summary>
/// 主表的列名列表
/// </summary>
[
Category("关键"),
Description("主表的列名列表")
]
public string ColsStr
{
get{return _colsStr;}
set{_colsStr = value;}
}
/// <summary>
/// 是否用回车键跳转焦点
/// </summary>
[
Category("关键"),
Description("是否用回车键跳转焦点")
]
public bool IsTabChg
{
get{return _isTabChg;}
set{_isTabChg = value;}
}
/// <summary>
/// 选择SQL语句.注意列名不能用'*'
/// </summary>
[
Category("关键"),
Description("选择SQL语句.注意列名不能用'*'")
]
public string SelSql
{
get{return (string)ViewState["lrcSelSql"];}
set{ViewState["lrcSelSql"] = value;}
}
/// <summary

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: