Click here to Skip to main content
15,888,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have applied pagination for my repeater control ,
but now the problem is as the number of pages grows that number of page number in poagination are getting duisplayed ,,, I dont want 100 of page numbers to be displayed into my repeater footer.. I want to show around 5 number and for next it will generate automatically as I click on next next

What I have tried:


<asp:Repeater ID="rptPaging" runat="server" OnItemCommand="rptPaging_ItemCommand">
<itemtemplate>
<asp:LinkButton ID="btnPage"
Style="padding: 8px; margin: 2px; background: #ffa100; border: solid 1px #666; font: 8pt tahoma;"
CommandName="Page" CommandArgument="<%# Container.DataItem %>"
runat="server" ForeColor="White" Font-Bold="True"><%# Container.DataItem %>






private void FillGridview()
{
try
{
DataSet dsState = new DataSet();
dsState = objStateMaster_M.GetAllStates();
ViewState["DtDate"] = dsState.Tables[0];
if (dsState != null)
{
//Create the PagedDataSource that will be used in paging
PagedDataSource pgitems = new PagedDataSource();
pgitems.DataSource = dsState.Tables[0].DefaultView;
pgitems.AllowPaging = true;

//Control page size from here
pgitems.PageSize = 5;
pgitems.CurrentPageIndex = PageNumber;
if (pgitems.PageCount > 1)
{
rptPaging.Visible = true;
ArrayList pages = new ArrayList();
for (int i = 0; i <= pgitems.PageCount - 1; i++)
{
pages.Add((i + 1).ToString());
}
rptPaging.DataSource = pages;
rptPaging.DataBind();
}
else
{
rptPaging.Visible = false;
}

rptState.DataSource = pgitems;
rptState.DataBind();
}
else
{
rptState.DataSource = null;
rptState.DataBind();
}
}
catch (Exception ex)
{

}
}
Posted
Comments
Sinisa Hajnal 29-Feb-16 7:01am    
I would suggest you increase page size first if possible. Then create some logic to show current page and +- 5 on each side. Provide first and last buttons and you're done.

But you have to program it, it doesn't come by default (that I know of)

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