DataGrid custom paging navigation

xiaoxiao2021-03-06  51

DataGrid custom paging navigation

effect:

Let DataGrid's own paging achieve this effect [1] [2] [3] [4] [5] [6]

private void grid_ItemCreated (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {if (e.Item.ItemType == ListItemType.Pager) {foreach (Control c in e.Item.Cells [0] .Controls) { IF (c is label) // Current page {label lblpage = (label) c; // lblpage.forecolor = system.drawing.colortranslator.fromhtml ("# e

78A

29 "); // # e

78A

29, # ff0000 // lblpage.font.bold = true; lblpage.text = "[

78A

29> lblpage.text " ]"; // (((Label )c ).ForeColor = system.drawing.color.green; // Break;} if (c is LinkButton) // Link Other Pages {LinkButton LinkButton = (LinkButton) C; LinkButton.Text = "[" LinkButton.Text "]";}}}}

Auto number in controls such as DataGrid:

Add a template column:

>

Creating complex heads in DataGrid

Method 1: Implement with Table

"); strText.Append (" "); Strtext.Append (""); strText.Append ("
< / TD> Form Top

Form bottom end

Method 2: Dynamic generating head

Generate a double sheet head: private void grid_itemdatabase (Object sender, system.web.ui.webcontrols.dataGriditeMeventArgs e) {

IF (E.Item.itemType == ListItemType.Header) {// E.Item.cells [0] .COLUMNSPAN = 1; // This is the first column of cross-column StringBuilder Strtext = New StringBuilder (); strText. Append ("// "); strText.Append ("

Life illumination "); strText.Append (" General lighting " ); StrText.Append (" Work 25 "); Strtext.Append (" Agriculture "); Strtext.Append (" Total "); strText.Append (" "); strText.Append ("
" E.Item.cells [ 0] .text); E.Item.cells [0] .Text = start.toTOString ();

}

}

The entire header content:

E.Item.cells [0] .Text = content added up the style of the header.

Life lighting

General lighting

Work industry

agriculture

total

Generate a three-story head:

IF (E.Item.itemType == ListItemType.Header) {StringBuilder Strtext = new stringbuilder (); stringbuilder (); strText.Append (""); strText.Append ("

The month "); StrText.Append (" ");

Strtext.Append ("

Resident "); Strtext.Append (" General "); Strtext .Append (" Work 25 "); Strtext.Append ("");

Strtext.Append ("

" E.Item.cells [0] .text); E.Item.cells [0] .text = strText.toString (); }

Month

Resident

general

Work industry

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

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.060, SQL: 9