ASP.NET Dual Row Double Row Cross-column cross-bank complex head design experience!

xiaoxiao2021-03-06  41

First, DataGrid property setting 1.ALLOWPAGING: TRUE 2. PageStyle-> Position: Topandbottom 3. Optional: PageStyle-> Horizonalign: center (display) 4. Optional: ItemStyle-> Horizonalign: Center (make text Credit) Second, Code Part 1. First, make the DataGrid bind a table in the database, for example: private void page_load (object sender, system.eventargs e) {// Place the user code here to initialize the page if (! IsPostBack) {SqlConnection myConn = new SqlConnection ( "server = localhost; uid = sa; pwd = sa; database = db_test"); SqlDataAdapter da = new SqlDataAdapter ( "Select * from individuals", myConn); DataSet ds = new DataSet ( ); DA.FILL (DS, "GR"); DGGEREN.DATASOURCE = DS.TABLES ["GR"]. Defaultview; dggeren.databind ();

} 2. Add the processing function of the Itemcreated event to DataGrid, 3. To determine the position of two (up and down) Pager in the DataGrid, we can use a global variable to determine. Define a global variable private int m_CreatePageTimes = 0; 4. Add the contents of the event handler ItemCreated DataGrid follows: private void dgGeRen_ItemCreated (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {switch (e.Item. ItemType) {//case (ListItemType.Pager): {if (m_createpagetimes == 0) {dataGridItem Row = (DataGridItem) E.Item; row.cells.clear (); //row.backcolor= Color.navy; // background color //row.forecolor=Color.Red; // foreground row.horizontalalign = horizontalalign.center; // Make text homage display

TableCell Cell0 = new TableCell (); cell0.rowspan = 2; cell0.controls.add (New LitralControl ("Name");

TableCell Cell1 = new Tablecell (); Cell1.Columnspan = 2; // The default columnspan value is 1 cell1.text = "housing address information"; // can be: cell1.controls.add (New LitralControl ("housing address information"));

// Tablecell Cell2 = new Tablecell (); //cell2.controls.add(new LitralControl (")); TableCell Cell2 = New TableCell (); cell2.rowspan = 2; cell2.text =" Birth Date "; ROW .Cells.add (cell0); row.cells.add (cell1); row.cells.add (Cell2);

M_CreatePageTimes ;} Break;} Case ListItemType.Header: {DataGridItem Head = (DataGridItem) E.Item; Head.cells.clear ();

//hhead.vertagelign=vertageAlign.middle; //head.horizontalalign=hor;

// TableCell Cell00 = new TableCell (); //cell00.rowspan=2; //rell00.text= "Name";

Tablecell Cell01 = New Tablecell (); Cell01.Text = "Line Number";

Tablecell Cell02 = new Tablecell (); cell02.text = "room number";

// Tablecell Cell03 = new Tablecell (); //cell03.text= "Birth Date";

///head.cells.add(Cell00); Head.cells.Add (Cell01); Head.cells.Add (Cell02); //head.cells.add(Cell03); Break;}

}

Third, the final effect is as follows:

http://dotnet.mblogger.cn/upimgs/dotnet.mblogger.cn/mark_lee/2005-2/2005_228786.jpg IV, I hope everyone is guided!

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

New Post(0)