//前台
<asp:TemplateField HeaderText="序号" InsertVisible="False">
<ItemTemplate>
<%#Container.DataItemIndex+1%>
</ItemTemplate>
</asp:TemplateField>
//后台---分页了之后进行累加。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{
int indexID = this.GridView1.PageIndex * this.GridView1.PageSize + e.Row.RowIndex + 1;
e.Row.Cells[0].Text = indexID.ToString();
}
}
GridView自动增加序号
最新推荐文章于 2024-09-10 21:41:16 发布