在DataGrid ASP.NET中编号序列号? [英] Numbering sequence number in DataGrid ASP.NET?
本文介绍了在DataGrid ASP.NET中编号序列号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在 DataGrid
ASP.NET控件中标记编号但未成功。有些人告诉我这个看起来像工作的链接,但它对我来说并不奏效。请帮助 - DataGrid
不 GridView
或 DataList
p>
I tried to mark numbering in DataGrid
ASP.NET control but unsuccessfully. Some guys show me the link that look like working but it does not work for me. Please help - DataGrid
not GridView
or DataList
.
<Columns>
<asp:TemplateColumn ItemStyle-CssClass="tdCenter">
<HeaderTemplate> No.</HeaderTemplate>
<asp:ItemTemplate>
<%# (grdAttDetails.PageSize * grdAttDetails.CurrentPageIndex) + Container.ItemIndex + 1%>
</asp:ItemTemplate>
</asp:TemplateColumn>
</Columns>
推荐答案
Datagrid:
<asp:DataGrid ID="DataGrid1" runat="server" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateColumn HeaderText="RowCount">
<ItemTemplate>
<%# (DataGrid1.PageSize * DataGrid1.CurrentPageIndex) + Container.ItemIndex + 1%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
PageIndexChanged事件:
PageIndexChanged Event:
protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
}
结果:
结果与分页:
第1页:
第2页:
这篇关于在DataGrid ASP.NET中编号序列号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文