Learning
Learning

Reputation: 20001

Paging for ASP.net Repeater control with functionality to show next 10 pages

I am using a paging function for repeater control and i have modified a script taken from following link

http://www.dotnetfunda.com/articles/article456-custom-seo-friendly-paging-with-aspnet-repeater-or-datalist-control-.aspx

i have modified it to some extent and it is working fine and paging is now displayed as

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

Paging function working fine but i need to modify script so that it will display first 5 Pages and next 5 page once user hits the next 10 Link along with Last and First Previous Functionality

Example based on above scenario

First - Previous 1 | 2 | 3 | 4 | 5 Next5 - Last

if i hit the Next5 link then it should display

First - 5Previous 6 | 7 | 8 | 9 | 10 Next - Last

Below is the code function and my stored procedure a

private string GetPagingDone(int thisPageNo, int totalCount, int pageSize, string pageName, int LangID, string extraQstringToAdd)
{
    int pageno = 0;
    int start = 0;
    int loop = totalCount / pageSize;
    int ilimit = 5;
    int remainder = totalCount % pageSize;
    StringBuilder strB = new StringBuilder("", 500);
    for (int i = 0; i < loop; i++)
    {
        pageno = i + 1;
        if (pageno.Equals(thisPageNo))
            strB.Append(pageno + "&nbsp; ");
        else
            strB.Append("<a href=\"" + pageName + "?start=" + start + "&page=" + pageno  +"&PageID=" + Request["PageId"] + "&Language=" + Request["Language"] + "\">" + pageno + "</a>  ");
        if (i + 1 == loop)
        { strB.Append("  "); }
        else 
        { strB.Append(" | "); }
        start += pageSize;
    }
    if (remainder > 0)
    {
        pageno++;
        if (pageno.Equals(thisPageNo))
            strB.Append("" + pageno + "&nbsp; ");
        else
            strB.Append("<a href=\"" + pageName + "?start=" + start + "&page=" + pageno + "&PageID=" + Request["PageId"] + "&Language=" + Request["Language"] + "\">" + pageno + "</a>  ");
    }

    return strB.ToString() + "";
}

ALTER PROCEDURE [dbo].[usp_ArticleListPaging]
        @startRowIndex int,
        @pageSize int,
        @LangID int,
        @totalCount int output
    AS
    BEGIN
        SET NOCOUNT ON;
        SET @totalCount = 0
        SET @startRowIndex = @startRowIndex + 1
        BEGIN
           SELECT * FROM ( Select art_Articles.*, ROW_NUMBER() OVER (ORDER BY art_Articles.ArticlePublishDate DESC) as RowNum
           FROM art_Articles WHERE art_Articles.ArticleActive = 1 AND art_Articles.ArticleVisible = 1 AND LanguageID =@LangID) as ArticleList
           WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @pageSize) - 1 ORDER BY ArticlePublishDate DESC
           SELECT @totalCount = Count(ArticleID) FROM art_Articles WHERE art_Articles.ArticleActive  = 1 AND art_Articles.ArticleVisible = 1 AND LanguageID =@LangID
        END
    END

I have to modify the same code to use this functionality. I tried if for several hours but could not get it right so . any help in this is highly appreciated

I am not sure why i am being given -ve for asking this kind of question

Upvotes: 0

Views: 13306

Answers (1)

Dave Walker
Dave Walker

Reputation: 3523

here is an example which extends the repeater to work with another inbuilt control called the 'DataPager' which should do all you want.

http://www.codeproject.com/Articles/45163/Extend-Repeater-to-support-DataPager

And another http://www.dot4pro.com/extend-repeater-support-datapager.html

Some examples on how to use it http://www.c-sharpcorner.com/uploadfile/nipuntomar/datapager-in-Asp-Net-3-5/

Upvotes: 1

Related Questions