Click here to Skip to main content
11,479,034 members (58,253 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
i want to implement custom paging(first,next,previous,last)with out link buttons and without using pagedatasource in repeater control in c#.net?

pls see the below link....

http://www.aspsnippets.com/Articles/Custom-Paging-in-ASP.Net-GridView-using-SQL-Server-Stored-Procedure.aspx

from the above link they are using populatepager function pls modify that function by adding next and previous logic ...pls help me out...

 
private void PopulatePager(int recordCount, int currentPage)
{
    double dblPageCount = (double)((decimal)recordCount / decimal.Parse(ddlPageSize.SelectedValue));
    int pageCount = (int)Math.Ceiling(dblPageCount);
    List<ListItem> pages = new List<ListItem>();
    if (pageCount > 0)
    {
        pages.Add(new ListItem("First", "1", currentPage > 1));
        for (int i = 1; i <= pageCount; i++)
        {
            pages.Add(new ListItem(i.ToString(), i.ToString(), i != currentPage));
        }
        pages.Add(new ListItem("Last", pageCount.ToString(), currentPage < pageCount));
    }
    rptPager.DataSource = pages;
    rptPager.DataBind();
}
 


i modified my code in below format with page size "5"...my next and previous logic is not working

 
  private void PopulatePager(int recordCount, int currentPage)
        {
       
            double dblPageCount = (double)((decimal)recordCount / PageSize);
            int pageCount = (int)Math.Ceiling(dblPageCount);
            if (pageCount > 1)
            {
 
               
                findex = currentPage - 5;
                
 
                //Set Last index value if current page less than 5 then last index added "5" values to the Current page else it set "10" for last page number
                if (currentPage > 5)
                {
                    //lindex = currentPage + 4;
                    //findex = lindex - 5;
                    lindex = currentPage + 4;
                    findex = currentPage;
                }
                else
                {
                    lindex = 5;
                }
 
                //Check last page is greater than total page then reduced it to total no. of page is last index
                if (lindex > pageCount)
                {
                    lindex = pageCount;
                    //findex = currentPageIndex;
                    findex = lindex - 1;
                }
 
                if (findex <= 0)
                {
                    findex = 1;
                }
 
                List<ListItem> pages = new List<ListItem>();
                if (pageCount > 1)
                {
                    pages.Add(new ListItem("First", "1", currentPage > 1));
                    if (findex > 1)
                    {
                        int index = findex - 1;
                        pages.Add(new ListItem("..", index.ToString(), true));
                    }
                    else
                    {
                        pages.Add(new ListItem("..", findex.ToString(), false));
                    }
                    for (int i = findex; i <= lindex; i++)
                    {
                       
                      pages.Add(new ListItem(i.ToString(), i.ToString(), i != currentPage));
                        
 
                    }
 
                    if (lindex >= 5 & lindex < pageCount)
                    {
                        lindex = lindex + 1;
                        pages.Add(new ListItem("..", lindex.ToString(), true));
                    }
                    else
                    {
                        pages.Add(new ListItem("..", lindex.ToString(), false));
                    }
                    pages.Add(new ListItem("Last", pageCount.ToString(), currentPage < pageCount));
                }
                rptPager.DataSource = pages;
                rptPager.DataBind();
            }
 

 
        }
 

pls change accordingly in above code with previous and next logic..
Posted 10-Jan-13 1:22am
Edited 10-Jan-13 1:26am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
deepisingh at 10-Jan-13 8:52am
   
i dont want by using link buttons..

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 200
1 F-ES Sitecore 195
2 Frankie-C 120
3 OriginalGriff 105
4 DamithSL 95
0 Sergey Alexandrovich Kryukov 7,880
1 OriginalGriff 7,341
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100