How to load the report from the database
To load a report from a database in the Bold Reports® ASP.NET MVC Report Viewer, convert the stored report data to a memory stream and assign it to the Stream option of reportOption.ReportModel. Use the approach that matches how the report data is stored.
How do I load a report from a byte array?
To load a report stored as a byte array, wrap the bytes in a MemoryStream and assign it to the report model stream in the Report Viewer Web API.
[NonAction]
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
byte[] bytes = ""; // provide your byte array report data
MemoryStream reportStream = new MemoryStream(bytes);
reportOption.ReportModel.Stream = reportStream;
}How do I load a report from a Base64 string?
To load a report stored as a Base64 string, convert the string to bytes, wrap them in a MemoryStream, and assign it to the report model stream in the Report Viewer Web API.
[NonAction]
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
string base64String = ""; // provide your base64 report data
byte[] bytes = System.Convert.FromBase64String(base64String);
MemoryStream reportStream = new MemoryStream(bytes);
reportOption.ReportModel.Stream = reportStream;
}How do I load a report from a string?
To load a report stored as a string, encode the string to bytes, wrap them in a MemoryStream, and assign it to the report model stream in the Report Viewer Web API.
[NonAction]
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
string reportData = ""; // provide your database report data
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(reportFile);
MemoryStream reportStream = new MemoryStream(bytes);
reportOption.ReportModel.Stream = reportStream;
}