How to Generate a .NET Banded Report in Your Desktop Application
Tags: webdev, dotnet, tutorial
Published: 2022-06-03 20:36:43

---
canonical_url: https://www.grapecity.com/blogs/how-to-generate-net-banded-report-in-your-desktop-application
description: Learn how to generate a .NET banded report in your desktop application. See more from ActiveReports today.
---

ActiveReports is a flexible .NET report generator with a complete set of controls and extensive API that allows you to design reports in your Visual Studio projects. This post will demonstrate how to create a banded report in ActiveReports.NET using code-based Section Reports. ActiveReports also has two other powerful and flexible report types. Please look at this [page](https://www.grapecity.com/activereportsnet/net-rdl-section-page-report-types) to learn more about our different report types.

### Launch Visual Studio

Let’s create a simple tabular report of our stock inventory grouped by each product category. We’ll use an existing Visual Studio project, though you can create a new one. We’ll right-click our reports directory and select _Add > New Item._ Select the ActiveReports 16 Section Report (code-based) in the resulting dialog box and enter a report name. 

![Add New Item](https://files.grapecity.com/gc-website-media/2vsjmjjt/01-addnewitem.png?width=500&height=250.56306306306308)

First thing, let's establish a connection to a JSON endpoint. On the Visual Studio 2022 toolbar, go to _Extensions > Report > Data Source_. Alternatively, you can click on the Data Source icon in the _Detail_ band of the report:

![Detail Band](https://files.grapecity.com/gc-website-media/5ihojfyt/02-detailband.png?width=500&height=240.09508716323296)

Go to the JSON tab of the _Report Data Source _dialog box. Type in your connection string and query in the appropriate fields as follows:

![Report Data Source](https://files.grapecity.com/gc-website-media/mi5jqlyi/03-reportdatasource.png?width=500&height=218.9922480620155)

If you need help creating your connection string, click on the _Build_ button next to _Connection String. _Here, you can easily configure your JSON connection. Similarly, if you need help crafting your query, click on the _Build_ button next to _JsonPath_, which will launch the JSON Query Designer. Once you are all done, click _OK_. 

You should have all your fields from the dataset in your Report Explorer. Let's right-click on _Fields>Calculated_ to add a custom field to our .NET report. 

![Report Explorer](https://files.grapecity.com/gc-website-media/be3h1tsi/04-reportexplorer.png?width=228&height=383)

We'll use this custom field to calculate the value of each product. To do so, we'll set the following properties: 

*   Name: Value
*   FieldType: Double
*   Formula: =UnitPrice*UnitsInStock

### Grouping Data

We want to group the data by CategoryID and aggregate the value of each grouping. Right-click the Details band and select _Insert > Group Header/Footer_. Click on the Group Header and set the DataField property to _CategoryID_ to group the report on this field. Also, set the BackColor property to _WhiteSmoke_. Finally, set the KeepTogether property to _True_. This ensures that the grouping will not be broken across multiple pages whenever possible.

At the top of the Group Header, add two labels ("Category:" and "Category Value:") vertically aligned. Next to each, drag and drop _CategoryId_ and _Value_ from the Fields section of your Report Explorer. The Value textbox will display the total value of the category. Therefore, we need to adjust some properties for this textbox:

*   OutputFormat: Currency
*   SummaryGroup: GroupHeader1
*   SummaryType: SubTotal

### Creating the Report Layout

At the bottom of the Group Header, add 4 Labels:

*   Product Name
*   Stock
*   Unit Price
*   Value

In the Details band, drag and drop _ProductName_, _UnitsInStock,_ and _UnitPrice_ from the Bound Fields and _Value_ from the Calculated fields. Adjust the size and position of the text boxes to align with their respective labels in the Group Header. Adjust the height of the Group Header, Detail, and Group Footer. At this point, your report layout will look like this: 

![Report Layout](https://files.grapecity.com/gc-website-media/q5ci22se/05-reportlayout.png?width=500&height=243.24324324324326)

Previewing, the sizing looks right now. We also see that the groups are kept together as much as possible. 

![Report Designer](https://files.grapecity.com/gc-website-media/dldn41mk/06-reportpreview.png?width=403.9634146341464&height=500)

Download this sample as an RPX file from the link below [inventory.rpx](https://files.grapecity.com/gc-website-media/53namnun/inventory.rpx)

Learn more about ActiveReports.NET features by visiting our [Online Demos](https://www.grapecity.com/activereportsnet/demos/).