This Snip of code shows you how to create Squence No on a Datagrid with Paging.
<asp:DataGrid id="DataGrid1" runat="server" PagerStyleNumericPages PageSize="10" AutoGenerateColumns="False" AllowPaging="True">
<Columns>
<asp:templatecolumn headertext="Row
Number">
<itemtemplate>
<%# (DataGrid1.PageSize*DataGrid1.CurrentPageIndex)+ Container.ItemIndex+1%>
</itemtemplate>
</asp:templatecolumn>
<asp:boundcolumn runat="server" DataField="CompanyName"
HeaderText="Company Name">
</asp:boundcolumn>
<asp:boundcolumn runat="server" DataField="Address"
HeaderText="Address">
</asp:boundcolumn>
</Columns>
</asp:DataGrid>
Tweak in the code is very simple, instead
of only using container.itemindex to get the sequence number. You need to
use Pagesize and currentpageindex to find out the starting number of that
page and then add container.itemindex to that.
0 comments:
Post a Comment