Tuesday, March 1, 2011

Create Customing Paging Links for ASP.NET Page

    private void Paging(DataView dv)
    {
        int totalPages = dv.Count / maxrow;
        int remainder = dv.Count % maxrow;
        //Response.Write(totalPages + "
" + remainder);
        if (remainder > maxrow && remainder!= 0)
        {
            totalPages += totalPages;
        }
        for(int i=1;i<=totalPages;i++)
        {
        HtmlAnchor lnkPage = new HtmlAnchor();
        lnkPage.HRef = this.Page.AppRelativeVirtualPath + "?" + this.Page.ClientQueryString.Replace(Session["page"].ToString(), "Page=" + i.ToString());
        lnkPage.Attributes.Add("class", "paging");
        lnkPage.InnerText = i.ToString();
        //Pager is a PlaceHolder
        pager.Controls.Add(lnkPage);       
        }

    }

No comments:

Post a Comment