Show Report in the Viewer

This sample project demonstrates how to add the HTML5 viewer on the ASPX page and display a simple report. To add the viewer, it is enough to add the StiWebViewer component from the Stimulsoft.Report.Web library.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Show_Report_in_the_Viewer.Default" %>
<%@ Register assembly="Stimulsoft.Report.Web" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title>Show report in the Viewer</title>
</head>
<body>
    <form id="form1" runat="server">
        <cc1:StiWebViewer ID="StiWebViewer1" runat="server" 
            OnGetReport="StiWebViewer1_GetReport" />
    </form>
</body>
</html>


To display the report, you should add the OnGetReport event, in which you need to load the report and, if required, to register the data.

protected void StiWebViewer1_GetReport(object sender, Stimulsoft.Report.Web.StiReportDataEventArgs e)
{
string reportPath = Server.MapPath("Reports/SimpleList.mrt");
StiReport report = new StiReport();
report.Load(reportPath);

string dataPath = Server.MapPath("Data/Demo.xml");
DataSet data = new DataSet();
data.ReadXml(dataPath);
report.RegData(data);

e.Report = report;
}


In the screenshot below you can see the result of the sample code.

Show Report in the Viewer