博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

動態更改GridView 的Page 頁碼的Style

Posted on 2007-04-12 09:25  徐正柱-  阅读(383)  评论(0编辑  收藏  举报

 

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Pager)
        {
            string name = ((TableRow)e.Row.Cells[0].Controls[0].Controls[0]).Cells[GridView1.PageIndex].Controls[0].GetType().ToString();
            switch (name)
            {
                case "System.Web.UI.WebControls.Label":
                    ((System.Web.UI.WebControls.Label)((TableRow)e.Row.Cells[0].Controls[0].Controls[0]).Cells[GridView1.PageIndex].Controls[0]).ForeColor = System.Drawing.Color.Red;
                    break;
            }
        }