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 = "&nbsp;&nbsp;" + strInitials.ToUpper() + "&nbsp;&nbsp;"
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 = "&nbsp;&nbsp;" + strInitials.ToUpper() + "&nbsp;&nbsp;"
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}
posted @ 2007-06-12 14:58  过河卒A  阅读(421)  评论(0编辑  收藏  举报