Count total rows of gridview with pagination

前端 未结 12 826
失恋的感觉
失恋的感觉 2020-12-03 12:02

I have a GridView with paging. When I try to count gridview row with gridview.rows.count, It gives me row count for current page only.

How can I get total rows of G

12条回答
  •  無奈伤痛
    2020-12-03 12:26

                   int a = grdvw.PageIndex;
                   int rowcount=0;
    
                    for (int i = 0; i < grdvw.PageCount; i++)
                    {
                        grdvw.SetPageIndex(i);
                        foreach (GridViewRow row in grdvw.Rows)
                        {
                            if (row.RowType == DataControlRowType.DataRow)
                            {
                              rowcount++;
                            }
                        }
                   }
    
                 grdvw.SetPageIndex(a);
    

提交回复
热议问题