locked
Gridview with many pages - Only reading the current pages - How to read all pages of the GridView RRS feed

  • Question

  • User1944504294 posted

    Hi,

    please help,

    How to count number of rows in the Gridview (having 5 pages or dynamically pages changes) and each row's userid.

    Only reading the current page count of the GridView.

    How to count all the pages count in the GridView and its id's

    Best regards,

    Renuka.V

    Tuesday, June 24, 2014 11:21 AM

Answers

  • User724169276 posted

    Hello Renuka,

    There is no readymade method to count this.Instead of counting gridview rows count the datasource rows.For example if you are using datatable get the count of the datatable.

    DataTable.Rows.Count

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 24, 2014 11:39 AM
  • User-417640953 posted

    Hi Renuka,

    Thanks for the post.

    As known that if we enable gridview to be AllowPaging, the gridview will render the currect page records to client side.

    So we cannot get all the records of the gridview from client side. As other member suggested, we can try to access gridview's datasource

    such as datatable and get the data which we want. Then show it to page as you want.

    Besides, if you want to get the count number of the gridview datasource and show it in the pagination.

    Please check below threads for some solutions.

    http://stackoverflow.com/questions/5788329/count-total-rows-of-gridview-with-pagination

    http://forums.asp.net/t/986566.aspx?Gridview+record+count+with+paging+How+to+

    Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 25, 2014 5:49 AM
  • User-1557429034 posted

    int  gvcount=ds.Tables[0].Rows.Count;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 26, 2014 12:37 AM

All replies

  • User724169276 posted

    Hello Renuka,

    There is no readymade method to count this.Instead of counting gridview rows count the datasource rows.For example if you are using datatable get the count of the datatable.

    DataTable.Rows.Count

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 24, 2014 11:39 AM
  • User-417640953 posted

    Hi Renuka,

    Thanks for the post.

    As known that if we enable gridview to be AllowPaging, the gridview will render the currect page records to client side.

    So we cannot get all the records of the gridview from client side. As other member suggested, we can try to access gridview's datasource

    such as datatable and get the data which we want. Then show it to page as you want.

    Besides, if you want to get the count number of the gridview datasource and show it in the pagination.

    Please check below threads for some solutions.

    http://stackoverflow.com/questions/5788329/count-total-rows-of-gridview-with-pagination

    http://forums.asp.net/t/986566.aspx?Gridview+record+count+with+paging+How+to+

    Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 25, 2014 5:49 AM
  • User-1557429034 posted

    int  gvcount=ds.Tables[0].Rows.Count;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 26, 2014 12:37 AM