My ASP.Net Core RDLC Report is working fine but tried to hide row when the field value is zero by right click the rdlc report row and then click Row Visibility. In the Row Visibility dialog box I selected Show Or Hide based on an Expression Under Change display options and used this expression
IIf(Fields!StudentAmt.Value=0,True,False)
and got the following error.
ReportProcessingException: An unexpected error occurred while compiling expressions. Native compiler return value: ‘[BC30390] 'AspNetCore.ReportingServices.RdlExpressions.ExpressionHostObjectModel.DataRegionExprHost(Of TMemberType, TCellType).m_memberTreeHostsRemotable' is not accessible in this context because it is 'Friend
I am using Reference of AspNetCore.Reporting
for local Report
And this Second Error displayed as a result of this expression Format(Fields!OEndDate.Value, "MMM-yyyy")
IndexOutOfRangeException: Index was outside the bounds of the array.
My Controller
public IActionResult Report()
{
string mimtype = "";
int extension = 1;
Dictionary<string, string> parameters = new Dictionary<string, string>
{
{ "rpl", “Student Name” }
};
LocalReport localReport = new LocalReport(mypath);
localReport.AddDataSource("DataSet1", mydatasource);
var result = localReport.Execute(RenderType.Pdf, extension, parameters, mimtype);
return File(result.MainStream, "application/pdf");
}
CodePudding user response:
Are you using AspNetCore.Reporting
? Do not use any expressions, report will fail. This is limitation of this library.
If you wish to hide rows using the expression, I recommend you to use ReportViewerCore.NETCore
.
Below is my test, you can refer to it:
public IActionResult Report()
{
var test = _context.Table.ToList();
var path = $"{_webHostEnvironment.WebRootPath}\\Reports\\Report2.rdlc";
LocalReport report = new LocalReport();
report.ReportPath= path;
report.DataSources.Add(new ReportDataSource("DataSet1", test));
report.SetParameters(new[] { new ReportParameter( "rdl", "Student Name" ) });
byte[] pdf = report.Render("PDF");
return File(pdf, "application/pdf");
}
Before using the expression:
After using the expression:
Output Result:
More details about ReportViewerCore.NETCore
, you can refer to this link.
Your second error may just be a problem with data loading, you can refer to this link to solve it.