0

I have the following code to achieve a rowcount for my gridview

protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }

    protected void OnDataBound(object sender, EventArgs e)
    {
        lblTotal.Text = "Total Rows: " + (GridView1.DataSource as DataTable).Rows.Count;
    }

But what I am trying to achieve is for the row count to show something like the below, when using paging in the Gridview:

1 to 10 of 15 Records

Is there anyone who could help me expand this code.

Many thanks and much appreciated for any assistance.

badgerless
  • 45
  • 8
  • Can't you use PageIndex and PageSize for this? PageIndex * PageSize + 1 should be the first value and (PageIndex + 1) * PageSize the second, no? – Hinek Sep 06 '21 at 15:29
  • Not really helped... – badgerless Sep 08 '21 at 15:23
  • Maybe explain, why it didn't help, if you want somebody to help... – Hinek Sep 09 '21 at 17:32
  • Apologies, moved on now, but have another issue in the link below. https://stackoverflow.com/questions/69122790/gridview-bottompagerrow-returned-as-null-trying-to-populate – badgerless Sep 10 '21 at 11:06

0 Answers0