How to Create a .NET Report

What Is Data Binding?

Data binding is the process that connects an application user interface (UI) to a data object. If the binding has the correct settings and the data provides the proper notifications, when the data changes its value, the elements that are bound to the data will automatically display changes.

Data binding in ActiveReports is relatively straightforward. In this article and video, we’ll cover how to use a stored procedure as a dataset as well as binding to a generic SQL data table. We’re going to show data binding using the End User Designer. The end user designer can be launched by going to start, GrapeCity, select -- ActiveReports 12 designer.

We’ll cover how to use a stored procedure as a dataset as well as binding to a generic SQL data table. We’re going to show data binding using the end user designer. The end user designer can be launched by going to start -- GrapeCity -- and selecting ActiveReports 12 designer.

How to Data Bind in .NET Reporting

Step 1:

With the End User Designer open, we’ll first add a datasource connection. We’ll use my SQL server on the local machine and bind to the NorthWind database.

We’ll add a dataset connection and we’ll call it the CustomerDetails Stored Procedure. I’ll rename this dataset so I don’t confuse it with the second dataset I will be adding later for the parameter. We need to make sure the Command Type is set to StoredProcedure. As you can see, the stored procedure pulls certain fields from the Customers data table and filters it by a City parameter.

For now, we’ll pass a specific city value directly to the stored procedure for testing purposes. We’re going to add a table to the design surface to display the data from the stored procedure.

Step 2:

We want the user to be able to pick a city from a list and pass that to the stored procedure. To do this, we’ll first create another dataset specifically for that parameter. We’ll get distinct cities from the Customers data table. Validate it. Then, we’ll add a parameter to the report, name it cityParam and pass the ParamDS dataset we just created as the available values to populate the dropdown for this parameter. This process will prompt the user to select a city.

Step 3:

We need to pass that selection to the Stored Procedure to filter the dataset. To do so, we'll go back and edit the StoredProcedure data set and change the City parameter value to the value the user selects. So we’ll change the value field to the parameter the user would have selected. As you can see, the report filters based on the parameter we select.

Step 4:

Moving on to binding to a generic SQL table, I have a pre-made report file with a grouped table. Let’s establish a connection to my local instance of SQL server and the AdventureWorks database. Now, we can add a dataset and I’ll use one of my existing queries from my notes to select every record from the Products table that has a thumbnail image of the product. Let’s preview the report and switch to Galley Mode to better view all columns.

Note: We’re not showing the use of parameters in this instance, but you can find a more detailed discussion of parameters in the How to Add a Parameter to your Report video.

Data Binding video tutorial:

Additional tutorials are available on our ActiveReports blog page. Develop and deploy custom enterprise .NET reports with these award-winning complete reporting solutions by downloading a free 30-day trial.

Get ActiveReports Developer

Download the latest version of ActiveReports

Download Now!