Gridview total number of rows
-
Hi all, I need to get the total number of records into GridView outside the any event of gridview. If I use GridView1.Rows.Count, then it just returns me the total number of rows on the page. But if I have, 5 pages having 10 records per page and 45 records total, Rows.Count will return me 10 on the first 4 pages, and 5, on the last page. But I need to get total number of record without using the gridview1's datasource like dataset or dataview etc. I need to use only n only gridview1 property. Thanks, Sri...
-
Hi all, I need to get the total number of records into GridView outside the any event of gridview. If I use GridView1.Rows.Count, then it just returns me the total number of rows on the page. But if I have, 5 pages having 10 records per page and 45 records total, Rows.Count will return me 10 on the first 4 pages, and 5, on the last page. But I need to get total number of record without using the gridview1's datasource like dataset or dataview etc. I need to use only n only gridview1 property. Thanks, Sri...
Then why you are not counting the
Rows of your DataSource
?Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Then why you are not counting the
Rows of your DataSource
?Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
Thanks Abhijit, This one is an interview question as per interviewer I have only the gridview to get the total number of rows. I know we find same using the Datasource of gridview. But i don't have this option. I have to use only n only gridview Thanks, Sri...
-
Thanks Abhijit, This one is an interview question as per interviewer I have only the gridview to get the total number of rows. I know we find same using the Datasource of gridview. But i don't have this option. I have to use only n only gridview Thanks, Sri...
Have a look into this , Total Row Count of GridView[^]
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Thanks Abhijit, This one is an interview question as per interviewer I have only the gridview to get the total number of rows. I know we find same using the Datasource of gridview. But i don't have this option. I have to use only n only gridview Thanks, Sri...
Suppose GridView is gr
int k=gr.PageSize*(gr.PageCount-1);
gr.Currentpage=gr.PageCount-1;
int p=gr.Rows.Count ;
int GridRows= k+p;Try this I think you could get with a minor modification
-
Have a look into this , Total Row Count of GridView[^]
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
I am doing the following thing protected void Button1_Click(object sender, EventArgs e) { int recordCount; DataSet ds=(DataSet)GridView1.DataSource; recordCount = ds.Tables[0].Rows.Count; Response.Write(recordCount); } get error "Object reference not set to an instance of an object." stating ds.Tables[0] is null. I am not getting why this is happing even i am binding the gridview in page load under if(!IsPostBack). Thanks, Sri...
-
Suppose GridView is gr
int k=gr.PageSize*(gr.PageCount-1);
gr.Currentpage=gr.PageCount-1;
int p=gr.Rows.Count ;
int GridRows= k+p;Try this I think you could get with a minor modification
-
Thanks Nishant, You code is fine but we need to find the number of rows in the page of gridview to calculate the total number of rows in grid view. Any idea to find the number of rows in the last page?? Thanks, Sri...
Can you try with the paging to false and then check the recordcount after that u can make the paging as true.
-
Can you try with the paging to false and then check the recordcount after that u can make the paging as true.
Hi Prasant, I am doing the following things: protected void Button1_Click(object sender, EventArgs e) { GridView1.AllowPaging = false; Response.Write(GridView1.PageCount.ToString()); GridView1.AllowPaging = true; } Still getting 10 rows as rows on current page. Thanks, Sri...
-
Hi Prasant, I am doing the following things: protected void Button1_Click(object sender, EventArgs e) { GridView1.AllowPaging = false; Response.Write(GridView1.PageCount.ToString()); GridView1.AllowPaging = true; } Still getting 10 rows as rows on current page. Thanks, Sri...
Hi Srinandan, Set the page count to Last page
gr.CurrentPageIndex=gr.PageCount-1;
gr.Rows.CountYou will get the rows on the last page .