Full Edit WebGrid Control LrcGrid (5) - Constructor, Variables, and Properties

xiaoxiao2021-03-06  43

Full Edit WebGrid Control LrcGrid (5) - Constructor, Variables, and Properties

Lrcgrid inherits from System.Web.ui.WebControls.Table to implement inamingContainer interface

Metadata Attributes and Constructor: Metadata declares that the label and default properties of the control are specified for some properties of the control.

[

ToolboxData ("<{0}: lrcgrid runat = server> "),

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;

}

......

Declare a private variable:

And paging related private variables

# ion 有关 私 / 私 / 私 / 私 / *************************************************** Private string currentpageText = "" / b> {0} Page, a total of {1} page ";

Private string nopageselectedText = "No Selection page."

Private string queryPageCommandtext = "SELECT * FROM"

"(SELECT TOP {0} * from"

"(SELECT TOP {1} * from" 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

And attribute related private variables:

CHAR [] Chra = {','};

CHAR [] chrb = {'|'};

// private dataset _ds;

// private dataatable_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_ism;

Private bool_istabchg = true;

Private bool_io;

Private bool_isadd;

PRIVATE STRING_CONN;

Private color_titcolor;

Control properties, attributes are comments, no more detailed:

///

/// Foreign key indication /// [

Category ("key",

Description ("Foreign Key. Format: This Table Column Name | Foreign key column name | Foreign key column name to display | Foreign key table name, .....")

]

Public String Fkcol

{

Get {return _fkcol;}

Set {_fkcol = value;}

}

///

/// Whether to display the delete function /// [

Category ("key",

Description ("Whether to display delete function")

]

Public bool isdel

{

Get {return _isdel;}

Set {_Indel = Value;}

}

///

// / Whether to display the added function ///

[

Category ("key",

Description ("Whether to display the added function")

]

Public bool isadd

{

Get {return _isadd;

Set {_isadd = value;

}

///

/// Public property: Display column name ///

[

Category ("key",

Description ("Show Column Name")

]

Public String ColsStrCN

{

Get {return_colsstrcn;

Set {_COLSSTRCN = value;

}

///

/// The table name of the primary table ///

[

Category ("key",

Description ("Table Name of the Table")

]

Public String Tabn

{

Get {return tabn;}

Set {tabn = value;

}

///

/// Mode list list ///

[

Category ("key",

Description ("List of Home Table")

]

Public String Colsstr

{

Get {return _COLSSTR;

Set {_COLSSTR = Value;

}

///

/// Is it possible to use the Enter key jump focus ///

[

Category ("key",

Description ("Whether to use the Enter key jump focus")

]

Public Bool Istabchg

{

Get {return _istabchg;

Set {_istabchg = value;}}

///

/// Select the SQL statement. Do you know that the column name cannot be used with '*' ///

[

Category ("key",

Description ("Select SQL statement. Guise column names can't use '*'")

]

Public String Selsql

{

Get {return (string) ViewState ["lrcselsql"];

Set {ViewState ["Lrcselsql"] = value;

}

///

/// primary key column name, if there is a number of please use "," separated ///

[

Category ("key",

Description ("Primary key column name, if there are multiple please use /", / "separable")

]

Public String PriKey

{

Get {return _prikey;}

Set {_prikey = value;}

}

///

/// Title line color ///

[

Category ("key",

Description ("Title Color")

]

Public Color Titcolor

{

Get {return_titcolor;

Set {_titcolor = value;}

}

///

/// To edit columns, column name "," separated, 0 is not edited, 1 is full editing ///

[

Category ("key",

Description ("To edit the column, column names /", / "separan, 0 is not edited, 1 is full editing")

]

Public String Editcol

{

Get {return _editcol;

Set {_Editcol = Value;

}

[

Browsable (false)

]

Public String Updsql

{

Get {return ((htmlinputhidden) ("lrchid_updsql")))))))))). Value;

}

///

/ / / Whether to provide sorting function ///

[

Category ("key",

Description ("Is there a sort function")

]

Public Bool Issort

{

Get {return_issort;}

Set {_issort = value;}

}

///

/ / / Can I edit line ///

[

Category ("key",

Description ("Can I edit line")

]

Public Bool IsRowedit

{

Get {return _ismdit;}

Set {_ismrowedit = value;

}

///

/// The data set to be binding the room control can be modified, // / but please correspond to the above attributes ///

[

Browsable (false)

]

Public DataSet DBSET

{

get

{

IF (ViewState ["LRCDS"]! = null)

{

DataSet _dbset = new dataset ();

System.io.stringReader sr = new system.io.stringReader (String) ViewState ["Lrcds"]);

_dbset.readxml (SR);

Return_dbset;

}

Else

{

Return NULL;

}

}

set

{

IF (value! = null)

{

System.io.stringWriter SW = new system.io.stringwriter ();

Value.writexml (SW);

ViewState ["lrcds"] = sw.toString ();

}

Else

{

ViewState ["LRCDS"] = NULL;

}

}

}

///

/// Sort field name /// cannot be set to design ///

[

Browsable (false)

]

Public String Sortfield

{

get

{

String s = (string) ViewState ["lrcsortfield"];

Return ((s == null)? String.empty: s);

}

set

{

ViewState ["Lrcsortfield"] = Value;

}

}

///

/// Sort Type /// Do not set /// at design time

Browsable (false)

]

Public String SortType

{

get

{

String s = (string) ViewState ["lrcsomettype"];

Return ((s == null)? String.empty: s);

}

set

{

ViewState ["LrcsortType"] = Value;

}

}

///

/// Database connection string, read /// from Web.config by default

[

Category ("key",

Description ("Database Connection String")

]

Public String Conn

{

get

{

IF (_CONN == Null || _conn == "")

{

Return System.configuration.configurationSettings.AppSettings ["conn"];

}

Else

{

Return_Conn;

}

}

Set {_CONN = Value;

}

///

/// column name array ///

[

Browsable (false)

]

Public String [] cols

{

Get {return _COLSSTR.SPLIT (ChRA);

}

///

/// Display column name ///

[

Browsable (false)

]

Private string [] COLSA

{

Get {return _colsstrcn.split (chRA);

}

///

/// primary key column name /// [

Browsable (false)

]

Public string [] _prikeyar

{

Get {return_prikey.split (chRA);

}

///

/// Primary key column index group ///

[

Browsable (false)

]

Public String [] PrikeyIndex

{

get

{

String [] index = new string [_prikeyar.length];

For (int i = 0; i <_prikeyar.length; i )

{

For (INT II = 0; II

{

IF (cols [ii] == _prikeyar [i])

Index [i] = ii.tostring ();

}

}

Return Index;

}

}

///

/// Edit column name ///

[

Browsable (false)

]

Public string [] _Editcolar

{

Get {return _editcol.split (chRA);

}

///

/// Edit Column Core Argument Group ///

[

Browsable (false)

]

Public String [] EditcolIndex

{

get

{

String [] index = new string [_Editcolar.Length];

IF (_Editcolar.Length == 1 && _Editcola "==" 1 ")

{

INDEX [0] = "lrcalledit";

}

Else IF (_Editcolar.Length == 1 && _Editcola "==" 0 ")

{

INDEX [0] = "lrcnoedit";

}

Else

{

For (int i = 0; i <_editcolar.length; i )

{

For (INT II = 0; II

{

IF (cols [ii] == _editcolar [i])

Index [i] = ii.tostring ();

}

}

}

Return Index;

}

}

///

/// Foreign key column 2D array ///

[

Browsable (false)

]

Public String [,] fkcolarray

{

get

{

IF (_fkcol == "")

{

Return NULL;

}

Else

{

String [] a = _fkcol.split (chRA);

Int num = a.length;

String [,] fka = new string [num, 5];

For (int i = 0; i

{

String [] b = a [i] .split (chrb);

String fkindex = "";

For (INT II = 0; II

IF (cols [ii] == b [0])

{

fkindex = II.toString ();

FKA [I, 0] = fkindex;

}

}

For (int J = 0; j <4; j )

{

FKA [I, J 1] = B [J];

}

}

Return fka;

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-60979.html

New Post(0)