In this article we would see a simple trick for RadGridView for Silverlight 5 from Telerik. Well grouping is one of the major features of Telerik’s RadGridView. When you try to achieve the Count function for groups, you need to use aggregate functions and there you would get multiple counts for each column. We would see both the problem and the solution in this article.
Pre-Requisites for Running Sample
- Visual Studio 2010
- Silverlight 5 SDK
- Telerik RadControls for Silverlight 5
We would create a sample project.
Image may be NSFW.
Clik here to view.
As we have mentioned earlier, we would be targeting for Silverlight 5 version.
Image may be NSFW.
Clik here to view.
Make sure you have the following Telerik Assemblies added.
Image may be NSFW.
Clik here to view.
Just for displaying some sample data, the following code is used.
Image may be NSFW.
Clik here to view.
The following image is showing the RadGridView with sample data.
Image may be NSFW.
Clik here to view.
Problem
Try to group on of the columns. Then remove it and add it again.
Image may be NSFW.
Clik here to view.
This is because we have subscribed to the Grouped event of the RadGridView and we have added the aggregate functions there.
Image may be NSFW.
Clik here to view.
Such as:
Image may be NSFW.
Clik here to view.
The logic written above would work fine for first time for a single column, but when we do it again and again the repeated values started come. As you have seen in the above problem image.
The Solution:
The solution is very simple, the code we have already written need to be validated. The following logic would be working fine for the above problem statement.
Image may be NSFW.
Clik here to view.
Source Code: Click Here
Article as PDF: Click Here
Try My Codeplex Projects:
Filed under: Silverlight 5, Telerik, Visual Studio 2010 Tagged: Aggregate Function, Count Function, Grouping, RadGridView, Silverlight 5, Telerik Image may be NSFW.
Clik here to view.

Clik here to view.
