简体   繁体   中英

how can i use local parameter in rdlc report

i want to use value of variable name ReportTitle in rdlc report

my c# code is:

this.Report1.LocalReport.ReportPath = @"Report1.rdlc";
ReportParameterCollection reportParms1 = new ReportParameterCollection();
reportParms1.Add(new ReportParameter("ReportTitle", "My Report");
this.Report1.LocalReport.SetParameters(reportParms1);

rdlc code:

<ReportItems>
<Textbox name="ReportTitle">
<Value>=Parameters!ReportTitle.Value>
</Textbox>
</ReportItems>

i am getting exception error in setParameter()Line

Exception is "Error occured during local report processing" Inner Exception is "The definition of report is invalid" Inner Exception is " The Value expression for Textbox refers to an non existing report Parameter

You need to define a ReportParameter in your RDLC before using it:

<ReportParameters>
    <ReportParameter Name="ReportTitle">
        <DataType>String</DataType>
        <Prompt>ReportTitle</Prompt>
    </ReportParameter>
</ReportParameters>

In Visual Studio you can also use View > Report Data instead of directly modifying the RDLC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM