Creating a C1ReportViewer in Code
Creating a C1ReportViewer control in code is fairly simple. In the following steps you'll add a PlaceHolder control to the page, add an import statement, add and customize the C1ReportViewer, and add the control to the PlaceHolder.
Complete the following steps:
1. In Design view, navigate to the Visual Studio Toolbox and add a PlaceHolder control to your page.
2. Double-click the page to create the Page_Load event and switch to Code view.
3. Add the following statement to the top of the Code Editor to import the appropriate namespace:
Imports C1.Web.UI.Controls.C1Report.C1ReportViewer
• C#
using C1.Web.UI.Controls.C1Report.C1ReportViewer;
4. Add the following code to the Page_Load event to create and customize the C1ReportViewer control.
' Create a new C1ReportViewer.
Dim reportviewer1 As New C1ReportViewer
' Add the C1ReportViewer to the PlaceHolder control.
PlaceHolder1.Controls.Add(reportviewer1)
' Set the control's size.
reportviewer1.Height = 350
reportviewer1.Width = 600
• C#
// Create a new C1ReportViewer.
C1ReportViewer reportviewer1 = new C1ReportViewer();
// Add the C1ReportViewer to the PlaceHolder control.
PlaceHolder1.Controls.Add(reportviewer1);
// Set the control's size.
reportviewer1.Height = 350
reportviewer1.Width = 600;
|