This is a migrated thread and some comments may be shown as answers.

get the total count of my RadGrid

4 Answers 509 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 11 Apr 2012, 07:22 PM

Hi,

I am trying to get the total count of my RadGrid.

When I use GridResult.MasterTableView.Items.Count I get only the count on the actual page.

I've seen a post that disable the Paging, count the total, reactivate the paging and rebind. http://www.telerik.com/community/forums/aspnet-ajax/grid/total-record-count-after-filter.aspx

Is there any property that could return the total count ?

Thanks to everyone.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Apr 2012, 11:22 AM
Hi Pierre,

Please try the following approach:

C#:
protected void RadGrid1_ItemEvent(object sender, GridItemEventArgs e)
{
    if (e.EventInfo is GridInitializePagerItem)
    {
        int rowCount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount;
    }
}

Thanks,
Shinu.

0
Pierre
Top achievements
Rank 1
answered on 13 Apr 2012, 03:42 PM

Thanks a lot for your quick answer Shinu,

But where do I put this event in my ASPX ?

How this event is fired ?

I've found this on internet but it's not working.

<ClientSettings>
     <ClientEvents OnDataBound="RadGrid1_ItemEvent" />
</ClientSettings>

Could you lead me ?

0
Shinu
Top achievements
Rank 2
answered on 16 Apr 2012, 07:15 AM
Hi Pierre,

You can select the ItemEvent from the Events properties of the control.(Same as you attaching the ItemDataBound event)

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" onitemevent="RadGrid1_ItemEvent"></telerik:RadGrid>

C#:
protected void RadGrid1_ItemEvent(object sender, GridItemEventArgs e)
{
    if (e.EventInfo is GridInitializePagerItem)
    {
        int rowCount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount;
    }
}

Thanks,
Shinu.
0
Pierre
Top achievements
Rank 1
answered on 16 Apr 2012, 04:45 PM
Thanks a lot Shinu, it's perfect.
Tags
Grid
Asked by
Pierre
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Pierre
Top achievements
Rank 1
Share this question
or