min10

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

 

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    
if (e.Row.RowType == DataControlRowType.Pager)
    {
        System.Web.UI.ControlCollection cls 
= e.Row.Controls[0].Controls[0].Controls[0].Controls;
        
for (int i = 0; i < cls.Count; i++)
        {
            
string s = cls[i].Controls[0].GetType().ToString().Trim();

            
if (s == "System.Web.UI.WebControls.DataControlPagerLinkButton")
            {
                System.Web.UI.WebControls.LinkButton lb1 
= (System.Web.UI.WebControls.LinkButton)cls[i].Controls[0];
                System.Web.UI.WebControls.LinkButton lb2 
= (System.Web.UI.WebControls.LinkButton)cls[cls.Count - 2].Controls[0];

                
if (lb1.Text.Contains(""))
                {
                    lb1.Text 
= "<<";
                }

                
if (lb2.Text.Contains(""))
                {
                    lb2.Text 
= ">>";
                }
            }

            
if (s == "System.Web.UI.WebControls.Label")
            {
                System.Web.UI.WebControls.Label lb 
= (System.Web.UI.WebControls.Label)cls[i].Controls[0];
                
//lb.Text = "第" + lb.Text + "页"; 
                lb.ForeColor = System.Drawing.Color.Red;
                lb.Font.Bold 
= true;
            }
        }
    } 
}

 

例子中GridView分页模式选的是:NumericFirstLast

posted on 2009-03-23 15:36  min10  阅读(577)  评论(0编辑  收藏  举报