复制代码 代码如下:
<asp:TemplateField HeaderText="序号" InsertVisible="False">
<ItemTemplate>
<%#Container.DataItemIndex+1%>
</ItemTemplate>
</asp:TemplateField>
复制代码 代码如下:
<asp:TemplateField HeaderText="序号" InsertVisible="False">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:Label runat="server" Text='<%# this.GridView1.PageIndex * this.GridView1.PageSize + this.GridView1.Rows.Count + 1%>' />
</ItemTemplate>
</asp:TemplateField>
复制代码 代码如下:
<asp:BoundField HeaderText="序号" ></asp:BoundField>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{
int indexID = this.GridView1.PageIndex * this.myGridView.PageSize + e.Row.RowIndex + 1;
e.Row.Cells[0].Text = indexID.ToString();
}
}
新闻热点
疑难解答
图片精选