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