動態更改GridView 的Page 頁碼的Style

 

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;
            }
        }

原文地址:https://www.cnblogs.com/HondaHsu/p/709991.html