Click here to Skip to main content
15,119,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The serial numbers should be correct in the consecutive pages.


What I have tried:

I tried providing serial number directly from the database using offset calculations. I also tried providing the 'Container.ItemIndex + 1'. Can someone provide a better solution?
Posted
Updated 28-Aug-18 7:18am
v2
Comments
Mike V Baker 27-Aug-18 11:45am
   
This question doesn't give me any clue what you're trying to do. In the 'What I have tried' section you need to include the code you're using, what you expect it to do, and what it's actually doing.

Assuming you're using the ListView control[^], you'll need to use Container.DataItemIndex instead of Container.ItemIndex.

ListViewItem.DataItemIndex Property (System.Web.UI.WebControls) | Microsoft Docs[^]

HTML
<ItemTemplate>
    <%#: Container.DataItemIndex + 1 %>
    ...
   
Comments
jazygift 28-Aug-18 12:23pm
   
I tried that one and still the next page index number starts from 1.
Richard Deeming 28-Aug-18 12:25pm
   
How are you binding the data to the ListView?
jazygift 28-Aug-18 12:35pm
   
pagininfo.Offset = (pagininfo.CurrentPage - 1) * pagininfo.PageCount;
pagininfo.SortColumn = hiddenSort.Value;
DataTable dt = performance.GetAll(pagininfo);
Richard Deeming 28-Aug-18 12:39pm
   
So the ListView doesn't actually know anything about which page it's on?

Store the index of the first record in the page in a public property, backed by ViewState. Update the offset when you bind the ListView. Add the value of that property to the index you display.

public int FirstRecordIndex
{
    get { return (int?)ViewState["FirstRecordIndex"] ?? 0; }
    set { ViewState["FirstRecordIndex"] = value; }
}

<ItemTemplate>
    <%# FirstRecordIndex + Container.DataItemIndex + 1 %>
   ...
jazygift 28-Aug-18 13:05pm
   
This one worked !!!
Thanks a lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900