DataGRID自定义分页样式
1public void ItemCreated(object sender, DataGridItemEventArgs e)
2{
3 ListItemType lit = e.Item.ItemType;
4 if (lit == ListItemType.Pager)
5 {
6 String strInitials;
7
8 TableCell pager = (TableCell) e.Item.Cells[0];
9 for(int i=0; i<pager.Controls.Count; i++)
10 {
11 object o = pager.Controls[i];
12 if (o is LinkButton)
13 {
14 strInitials = ((ArrayList)ViewState["PageMap"])[i/2].ToString();
15 LinkButton lb = (LinkButton) o;
16 lb.Text = " " + strInitials.ToUpper() + " ";
17 }
18 else
19 if (o is Label)
20 {
21 strInitials = ((ArrayList)ViewState["PageMap"])[i/2].ToString();
22 Label l = (Label) o;
23 l.Text = " " + strInitials.ToUpper() + " ";
24 l.Font.Bold = true;
25 l.Style["height"] = "20px;";
26 l.BackColor = grid.HeaderStyle.BackColor;
27 l.ForeColor = grid.HeaderStyle.ForeColor;
28
29 l.BorderWidth = 1;
30 l.Style["border-top"] = "gray outset 1px";
31 l.Style["border-left"] = "gray outset 1px";
32 l.Style["border-right"] = "gray outset 1px";
33 l.Style["border-bottom-color"] = "gray";
34 }
35 }
36 }
37}
2{
3 ListItemType lit = e.Item.ItemType;
4 if (lit == ListItemType.Pager)
5 {
6 String strInitials;
7
8 TableCell pager = (TableCell) e.Item.Cells[0];
9 for(int i=0; i<pager.Controls.Count; i++)
10 {
11 object o = pager.Controls[i];
12 if (o is LinkButton)
13 {
14 strInitials = ((ArrayList)ViewState["PageMap"])[i/2].ToString();
15 LinkButton lb = (LinkButton) o;
16 lb.Text = " " + strInitials.ToUpper() + " ";
17 }
18 else
19 if (o is Label)
20 {
21 strInitials = ((ArrayList)ViewState["PageMap"])[i/2].ToString();
22 Label l = (Label) o;
23 l.Text = " " + strInitials.ToUpper() + " ";
24 l.Font.Bold = true;
25 l.Style["height"] = "20px;";
26 l.BackColor = grid.HeaderStyle.BackColor;
27 l.ForeColor = grid.HeaderStyle.ForeColor;
28
29 l.BorderWidth = 1;
30 l.Style["border-top"] = "gray outset 1px";
31 l.Style["border-left"] = "gray outset 1px";
32 l.Style["border-right"] = "gray outset 1px";
33 l.Style["border-bottom-color"] = "gray";
34 }
35 }
36 }
37}