protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {      

 //显示页数量和当前页数
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            int num = GridView1.PageIndex + 1;
            e.Row.Cells[2].Text = "第" + num + "页/共" + GridView1.PageCount + "页";
        }

//第一页

GridView记录自动序号的两种效果 

//最后一页

GridView记录自动序号的两种效果

////自动附加序号(从第一条到最后一条)
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Text = Convert.ToString(e.Row.DataItemIndex + 1);
        }


//第一页

GridView记录自动序号的两种效果

//最后一页

GridView记录自动序号的两种效果

        ////自动附加序号(单页序号)
        //if (e.Row.RowIndex != -1)
        //{
        //    int id = e.Row.RowIndex + 1;
        //    e.Row.Cells[0].Text = id.ToString();
        //}

}

相关文章:

  • 2021-08-30
  • 2022-03-03
  • 2022-12-23
  • 2021-10-10
  • 2022-02-19
  • 2022-12-23
猜你喜欢
  • 2022-01-04
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案