Walkthrough: Web Viewer Control
The ActiveReports WebViewer control allows you to easily publish simple reports to the web for viewing in the browser. The client machine will not require ActiveReports or ASP.NET to be installed. The WebViewer also takes advantage of a report queuing technology to ensure the reports are executed and outputted efficiently. To use the WebViewer you will select an ActiveReport using the Report property of the WebViewer in the property list and set the ViewerType property to the viewer of your choice. Alternatively, you can set the Report property programmatically to a new instance of an ActiveReport class.
This walkthrough is split up into the following activities:
- Adding an ActiveReport to an ASP.NET Web application
- Connecting the report to a data source
- Adding controls to the report to contain data
- Adding the ActiveReports WebViewer control to the Web Form
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
You must also have access to Internet Information Services either from your computer
or from the server. You must also run the "Configure Web Sample" option from the Data
Dynamics ActiveReports for .NET program menu from your Windows Start button.
When you have completed this walkthrough, you will have a report that looks similar
to the following.

Adding an ActiveReport to an ASP.NET Web application
To add an ActiveReport to your project
- Open a new ASP.NET Web application in Visual Studio.
- Click on Project > Add New Item.
- Select ActiveReports file and rename the file rptWebView.
- Click Open.
Connecting the report to a data source
To connect the report to a data source
- Click on the yellow report DataSource icon in the Detail section.
This brings up the report DataSource dialog box.
- Click on Build...
- Select Microsoft Jet 4.0 OLE DB Provider and click Next >>.
- Click on the ellipsis to browse for the access path to NWind.mdb. Click Open
once you have selected the appropriate access path.
- Click OK to continue.
- In the Query field, type "Select * from products ORDER BY categoryID, productname".
- Click OK to return to the report design surface.
Adding controls to the report to contain data
To add controls to the report
- Add a GroupHeader/Footer section to rptWebView.
- Make the following changes to the group header:
- Change the name to ghProducts
- Change the DataField property to CategoryID
- Change the GroupKeepTogether property to FirstDetail
- Change the KeepTogether property to True
- Add the following controls to the GroupHeader section:
| Control |
Name |
Text/Caption |
Location |
| Label
|
lblProductName
|
Product Name
|
0, 0
|
| Label
|
lblQuantityPerUnit
|
Quantity Per Unit
|
1.1875, 0
|
| Label
|
lblInStock
|
In Stock
|
2.5625, 0
|
| Label
|
lblUnitPrice
|
Unit Price
|
4, 0
|
- Add the following controls to the Detail section:
| Control |
DataField |
Name |
Text/Caption |
Location |
OutputFormat |
| TextBox |
ProductName |
txtProductName |
Product Name |
0, 0 |
(Empty string) |
| TextBox |
QuantityPerUnit |
txtQuantityPerUnit |
Quantity Per Unit |
1.1875, 0 |
(Empty string) |
| TextBox |
UnitsInStock |
txtInStock |
Units In Stock |
2.5625, 0 |
(Empty string) |
| TextBox |
UnitPrice |
txtUnitPrice |
Unit Price |
4, 0 |
Currency |
Adding the ActiveReports WebViewer control to the Web Form
- Click on the ActiveReport WebViewer control in the appropriate toolbox and
drag it onto WebForm1.
- Adjust the size according to your needs.
- Change the Report property to rptWebView.
- Make sure the ViewerType property is set to HtmlViewer.
Note To view the report
in PDF format, change the ViewerType property to AcrobatReader. To use the ActiveX
Viewer, change the ViewerType property to ActiveXViewer and paste the ActiveX viewer
.cab file in your project folder (for help with this, see "Using
ActiveX Viewer Control on the Web").
ASP.NET Web Sample | Samples | Walkthroughs | OutputFormat Strings | GroupKeepTogether enumeration
Copyright © 2005 Data Dynamics, Ltd. All rights reserved.