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> {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;
}
......
Declare a private variable:
And paging related private variables
# ion 有关 私 / 私 / 私 / 私 / *************************************************** Private string currentpageText = "" / b> {0} Page, a total of b> {1} page b> ";
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:
///
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;}
}
///
Category ("key",
Description ("Whether to display delete function")
]
Public bool isdel
{
Get {return _isdel;}
Set {_Indel = Value;}
}
///
[
Category ("key",
Description ("Whether to display the added function")
]
Public bool isadd
{
Get {return _isadd;
Set {_isadd = value;
}
///
[
Category ("key",
Description ("Show Column Name")
]
Public String ColsStrCN
{
Get {return_colsstrcn;
Set {_COLSSTRCN = value;
}
///
[
Category ("key",
Description ("Table Name of the Table")
]
Public String Tabn
{
Get {return tabn;}
Set {tabn = value;
}
///
[
Category ("key",
Description ("List of Home Table")
]
Public String Colsstr
{
Get {return _COLSSTR;
Set {_COLSSTR = Value;
}
///
[
Category ("key",
Description ("Whether to use the Enter key jump focus")
]
Public Bool Istabchg
{
Get {return _istabchg;
Set {_istabchg = value;}}
///
[
Category ("key",
Description ("Select SQL statement. Guise column names can't use '*'")
]
Public String Selsql
{
Get {return (string) ViewState ["lrcselsql"];
Set {ViewState ["Lrcselsql"] = value;
}
///
[
Category ("key",
Description ("Primary key column name, if there are multiple please use /", / "separable")
]
Public String PriKey
{
Get {return _prikey;}
Set {_prikey = value;}
}
///
[
Category ("key",
Description ("Title Color")
]
Public Color Titcolor
{
Get {return_titcolor;
Set {_titcolor = value;}
}
///
[
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;
}
///
[
Category ("key",
Description ("Is there a sort function")
]
Public Bool Issort
{
Get {return_issort;}
Set {_issort = value;}
}
///
[
Category ("key",
Description ("Can I edit line")
]
Public Bool IsRowedit
{
Get {return _ismdit;}
Set {_ismrowedit = value;
}
///
[
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;
}
}
}
///
[
Browsable (false)
]
Public String Sortfield
{
get
{
String s = (string) ViewState ["lrcsortfield"];
Return ((s == null)? String.empty: s);
}
set
{
ViewState ["Lrcsortfield"] = Value;
}
}
///
Browsable (false)
]
Public String SortType
{
get
{
String s = (string) ViewState ["lrcsomettype"];
Return ((s == null)? String.empty: s);
}
set
{
ViewState ["LrcsortType"] = Value;
}
}
///
[
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;
}
///
[
Browsable (false)
]
Public String [] cols
{
Get {return _COLSSTR.SPLIT (ChRA);
}
///
[
Browsable (false)
]
Private string [] COLSA
{
Get {return _colsstrcn.split (chRA);
}
///
Browsable (false)
]
Public string [] _prikeyar
{
Get {return_prikey.split (chRA);
}
///
[
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; } } /// [ Browsable (false) ] Public string [] _Editcolar { Get {return _editcol.split (chRA); } /// [ 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; } } /// [ 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; } } }