How to display power bi report server reports in reportviewer control in asp net

Introduction

ASP.NET is a popular language used for developing web applications. One common requirement in web is to Power BI Report Server reports in the ReportViewer control. In this article, we will explore how to this using ASP.NET.

Step 1: up the ReportViewer Control

The first step is to set up the ReportViewer control in your ASP.NET application. You can do this by adding the following code to your ASP.NET page:




The above code adds the necessary controls to your page for displaying the reports.

Step 2: the ReportViewer Control

Next, you need to configure the ReportViewer control to display the Power BI Report Server reports. This can be done by setting the necessary properties of the control. Here's an example:


protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        ReportViewer1.ProcessingMode = ProcessingMode.Remote;
        ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer");
        ReportViewer1.ServerReport.ReportPath = "/Reports/MyReport";
    }
}

In the above code, we set the ProcessingMode property to “Remote” to indicate that the report will be processed on the server. We also specify the ReportServerUrl and ReportPath properties to point to the of the report on the Power BI Report Server.

Step 3: Displaying the Report

Finally, you can display the report in the ReportViewer control by the Refresh method. Here's an example:


 void btnShowReport_Click( sender, EventArgs e)
{
    ReportViewer1.ServerReport.Refresh();
}

In the above code, we call the Refresh method of the ServerReport property to load and display the report in the ReportViewer control.

Conclusion

In this article, we have learned how to display Power BI Report Server reports in the ReportViewer control using ASP.NET. By following the steps outlined above, you can easily integrate Power BI reports into your ASP.NET web application.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents