Hi i need to display the count of rows of the grid in the top of my page. I used the follg code. but it shows the count of that page alone. i want all the rows irrespective of the pages. and i also need to display the pages co9unt. pls help me
protected void gridViewPograms_ItemDataBound(object sender, GridItemEventArgs e)
{
int i = gridViewPograms.Items.Count;
labelCount.Text = i.ToString();
}
Thanks,
Jeevitha
protected void gridViewPograms_ItemDataBound(object sender, GridItemEventArgs e)
{
int i = gridViewPograms.Items.Count;
labelCount.Text = i.ToString();
}
Thanks,
Jeevitha
2 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 01 Dec 2009, 06:34 AM
Hello Jeevitha,
Try the following code in order to get the total number of items.
CS:
-Shinu.
Try the following code in order to get the total number of items.
CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
RadGrid1.MasterTableView.AllowPaging = false; |
RadGrid1.Rebind(); |
Label1.Text = RadGrid1.MasterTableView.Items.Count.ToString(); |
RadGrid1.MasterTableView.AllowPaging = true; |
RadGrid1.Rebind(); |
} |
-Shinu.
Richard
commented on 11 Jul 2012, 06:36 PM
Top achievements
Rank 1
I'm joining the discussion a little late, but here goes:
On the server side I want to get the total number of rows/items in the grid without having to do an extra rebind.
As it currently stands. <grid>.Items.Count and <grid>.MasterTableView.Items.Count both return the number of items in the current page, not the total for the grid.
Rich Sorensen
On the server side I want to get the total number of rows/items in the grid without having to do an extra rebind.
As it currently stands. <grid>.Items.Count and <grid>.MasterTableView.Items.Count both return the number of items in the current page, not the total for the grid.
Rich Sorensen
Shinu
commented on 12 Jul 2012, 02:50 AM
Top achievements
Rank 2
Hi Richard,
Please try the following code snippet to get the total count of items irrespective of paging.
C#:
Thanks,
Shinu.
Please try the following code snippet to get the total count of items irrespective of paging.
C#:
protected
void
RadGrid1_ItemEvent(
object
sender, GridItemEventArgs e)
{
if
(e.EventInfo
is
GridInitializePagerItem)
{
int
rowCount = (e.EventInfo
as
GridInitializePagerItem).PagingManager.DataSourceCount;
}
}
Thanks,
Shinu.
Richard
commented on 12 Jul 2012, 03:10 PM
Top achievements
Rank 1
Thanks - the logic works.
However, it would be nice to have a property on the grid control that could be accessed after a rebind operation rather then implementing more event code which would be called repeatedly.
However, it would be nice to have a property on the grid control that could be accessed after a rebind operation rather then implementing more event code which would be called repeatedly.
Justin
commented on 28 Jul 2014, 10:05 PM
Top achievements
Rank 1
Try this:
int i = gridViewPograms.MasterTableView.VirtualItemCount
int i = gridViewPograms.MasterTableView.VirtualItemCount
Mark
commented on 29 Jul 2014, 01:38 PM
Top achievements
Rank 1
Hi Justin,
That wont do im afraid, that will give you the limit of what you set your virtual count at
That wont do im afraid, that will give you the limit of what you set your virtual count at
Allen
commented on 13 Oct 2021, 11:22 AM
Top achievements
Rank 2
Iron
Veteran
SO why can't you just set VirtualItemCount to the number of rows in the DataTable in Needs_DataSource ???
It's just a statistic in this case.
Allen
commented on 13 Oct 2021, 12:49 PM
Top achievements
Rank 2
Iron
Veteran
and this seems to work for a grid with 20K rows...
0
Hi All,
You can also give this approach a try:
Hope this helps.
Regards,
Eyup
Telerik
You can also give this approach a try:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridPagerItem)
{
GridPagerItem pagerItem = e.Item
as
GridPagerItem;
int
itemsCount = pagerItem.Paging.DataSourceCount;
Label1.Text =
"Total items count: "
+ itemsCount;
}
}
Hope this helps.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.