Display Count of Dynamic Grouping in RadGridView in Silverlight 5

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

  1. Visual Studio 2010
  2. Silverlight 5 SDK
  3. Telerik RadControls for Silverlight 5

We would create a sample project.

As we have mentioned earlier, we would be targeting for Silverlight 5 version.

Make sure you have the following Telerik Assemblies added.

Just for displaying some sample data, the following code is used.

The following image is showing the RadGridView with sample data.


Try to group on of the columns. Then remove it and add it again.

This is because we have subscribed to the Grouped event of the RadGridView and we have added the aggregate functions there.

Such as:

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.

Source Code: Click Here

Article as PDF: Click Here

Try My Codeplex Projects:

  1. Visual Studio Cleaner
  2. Auto Power Switch
  3. Auto Wall
  4. Application Scheduler
  5. Windows 8 Storage Helper