Hi
I have a radgrid in my page with Paging enabled, i want to show the Aggregate function for some of the columns. Assume that i have 100 records in grid, i set pagesize=50, so my 100 records will displayed in two pages(50 per page) and also i set Count Aggregate function for the EmployeeID Column, it displays the Count as 50 in first page and again 50 in second page but i want to show the count as 100 for that Column in all the pages.
Is there any possibility to do this? if it so please send me the solution.
Thanks
6 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 13 Oct 2011, 07:38 AM
Hello Sathya,
I have tried to reproduce your issue. I suppose you are trying to set the item count in ItemDataBound event, then it gives the count per page only. If you need to get the full count you can try the following approaches:
1)ASPX:
2)Try the following code if AutoGenerateColumns is set as true.
C#:
3) C#:
Thanks,
Princy.
I have tried to reproduce your issue. I suppose you are trying to set the item count in ItemDataBound event, then it gives the count per page only. If you need to get the full count you can try the following approaches:
1)ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
PageSize
=
"4"
ShowFooter
=
"true"
AutoGenerateColumns
=
"false"
AllowPaging
=
"true"
onitemdatabound
=
"RadGrid1_ItemDataBound"
onitemevent
=
"RadGrid1_ItemEvent"
oncolumncreated
=
"RadGrid1_ColumnCreated"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"EmployeeID"
HeaderText
=
"EmployeeID"
SortExpression
=
"EmployeeID"
UniqueName
=
"EmployeeID"
Aggregate
=
"Count"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"LastName"
HeaderText
=
"LastName"
SortExpression
=
"LastName"
UniqueName
=
"LastName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FirstName"
HeaderText
=
"FirstName"
SortExpression
=
"FirstName"
UniqueName
=
"FirstName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Title"
HeaderText
=
"Title"
SortExpression
=
"Title"
UniqueName
=
"Title"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
2)Try the following code if AutoGenerateColumns is set as true.
C#:
protected
void
RadGrid1_ColumnCreated(
object
sender, GridColumnCreatedEventArgs e)
{
if
(e.Column.UniqueName ==
"EmployeeID"
)
{
GridBoundColumn item = (GridBoundColumn)e.Column;
item.Aggregate = GridAggregateFunction.Count;
}
}
3) C#:
protected
void
RadGrid1_ItemEvent(
object
sender, GridItemEventArgs e)
{
if
(e.EventInfo
is
GridInitializePagerItem)
{
int
rowCount = (e.EventInfo
as
GridInitializePagerItem).PagingManager.DataSourceCount;
}
}
Thanks,
Princy.
0

Sathya
Top achievements
Rank 1
answered on 13 Oct 2011, 07:57 AM
Hi Princy
Thanks for your reply. Actually i am assigning Aggregate function for columns in ColumnCreated event only not in ItemDataBound event. Columns of my grid are dynamic so i cannot assign property for columns in design itself that's why i assign the aggregate function in column created event.
" (e.Column as GridBoundColumn).Aggregate = GridAggregateFunction.Avg "
Is there any other solution?
Thanks for your reply. Actually i am assigning Aggregate function for columns in ColumnCreated event only not in ItemDataBound event. Columns of my grid are dynamic so i cannot assign property for columns in design itself that's why i assign the aggregate function in column created event.
" (e.Column as GridBoundColumn).Aggregate = GridAggregateFunction.Avg "
Is there any other solution?
0
Hello Sathya,
If you are using Autogenerated columns do make sure that you have EnableLinqExpressions = true for the grid and you are running on the .NET 3.5/4.0 framework.
Regards, Tsvetoslav
the Telerik team
If you are using Autogenerated columns do make sure that you have EnableLinqExpressions = true for the grid and you are running on the .NET 3.5/4.0 framework.
Regards, Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Hello Sathya,
If you are using Autogenerated columns do make sure that you have EnableLinqExpressions = true for the grid and you are running on the .NET 3.5/4.0 framework.
Regards, Tsvetoslav
the Telerik team
If you are using Autogenerated columns do make sure that you have EnableLinqExpressions = true for the grid and you are running on the .NET 3.5/4.0 framework.
Regards, Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Sathya
Top achievements
Rank 1
answered on 14 Oct 2011, 10:38 AM
I am working on .NET 3.5 only and i set EnableLinqExpressions=true because my grid has AutogeneratedColumns=true. But still i am getting the wrong Aggregate function result.
0
Accepted
Hello Sathya,
Please, close the current thread and leave the discussion to the formal support ticket #472864. Once again, please, make sure that you have one ticket opened for one issue that you have encountered.
Greetings, Tsvetoslav
the Telerik team
Please, close the current thread and leave the discussion to the formal support ticket #472864. Once again, please, make sure that you have one ticket opened for one issue that you have encountered.
Greetings, Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now