1

My project is in dot net framework 4.0. One of the page has a huge number of records to be displayed in the gridview and hence I am using custom paging which is going fine. The problem is the pager which I have made using a repeater control:

<asp:Repeater ID="repeaterPaging" runat="server">
     <ItemTemplate>
         <asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text")%>'
          CommandArgument='<%#Eval("Value") %>'
          Enabled='<%#Eval("Enabled") %>'
          OnClick="lnkPage_Click"></asp:LinkButton>
     </ItemTemplate>
 </asp:Repeater>

The code that I am using to bind it:

int totalPages = totalRows / PageSize;

    if (totalRows % PageSize != 0)
        totalPages += 1;

    List<ListItem> pages = new List<ListItem>();

    if (totalPages > 1)
    {
        for (int i = 1; i <= totalPages; i++)
        {
            pages.Add(new ListItem(i.ToString(), i.ToString(), i != (PageIndex + 1)));
        }
    }

    repeaterPaging.DataSource = pages;
    repeaterPaging.DataBind();

and the output I am getting is:

Pager

which is not something I want. I want to have it something like:

1 2 3 4 5 ...

so that it should look somewhat pretty.

I don't have any idea to do it. Please help me out on this.

DeepakVerma
  • 99
  • 10
  • See https://www.aspsnippets.com/Articles/Using-DataPager-control-with-example-in-ASPNet.aspx and https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.datapager?view=netframework-4.8 – VDWWD Jun 08 '19 at 14:13
  • can you give me any specific example of gridview... I have never used listview – DeepakVerma Jun 08 '19 at 14:45
  • It also works with GridView – VDWWD Jun 08 '19 at 14:53

0 Answers0