locked
Have numbers and next, previous buttons RRS feed

  • Question

  • User-614943948 posted

    How can I have numbers and next previous buttons in paging that I am using for the gridview

    Saturday, June 3, 2017 8:38 AM

All replies

  • User-614943948 posted

    OK I found this code helpful and it worked.

    https://www.codeproject.com/Tips/463016/The-easiest-way-to-implement-NumericNextPrev-pagin

    Now I also want to implement first and last option. How can do that, this is my existing source code

    protected void grdReport_DataBound(object sender, EventArgs e)
            {
                if (grdReport.BottomPagerRow == null)
                    return;
    
                Table pagerTable = (Table)grdReport.BottomPagerRow.Controls[0].Controls[0];
    
                if (grdReport.PageIndex != 0)
                {
                    TableCell prevCell = new TableCell();
    
                    HyperLink hlPrevious = new HyperLink();
                    hlPrevious.Text = "<<";
                    hlPrevious.NavigateUrl = ClientScript.GetPostBackClientHyperlink(grdReport, String.Format("Page${0}", grdReport.PageIndex));
    
                    prevCell.Controls.Add(hlPrevious);
    
                    pagerTable.Rows[0].Cells.AddAt(0, prevCell);
                }
    
                if (grdReport.PageIndex != grdReport.PageCount - 1)
                {
                    TableCell nextCell = new TableCell();
    
                    HyperLink hlNext = new HyperLink();
                    hlNext.Text = ">>";
                    hlNext.NavigateUrl = ClientScript.GetPostBackClientHyperlink(grdReport, String.Format("Page${0}", grdReport.PageIndex + 2));
    
                    nextCell.Controls.Add(hlNext);
    
                    pagerTable.Rows[0].Cells.Add(nextCell);
                }
            }

    Saturday, June 3, 2017 8:58 AM
  • User-707554951 posted

    Hi maverick786us,

    I think that my reply in the following thread will be helpful for you:

    https://forums.asp.net/t/2123302.aspx?Format+Pager+in+a+GridView

    Best regards

    Cathy

    Wednesday, June 14, 2017 2:51 AM