how to add parameters in report viewer?

后端 未结 3 1982
执笔经年
执笔经年 2021-02-13 02:37

HY! I have a form application in visual studio 2010 and I want to create a report with report viewer and to add some parameters. I tried to add parameters from code but it didn`

相关标签:
3条回答
  • 2021-02-13 02:57

    So when you create report definition (rdl or rdlc file) you have to add parameters with exactly the same names. So for your case you have to add datastart and dataStop parameters. To do it just click Parameters in Report Data Window and click add new.

    0 讨论(0)
  • 2021-02-13 02:58

    The error you get is because you try to specify your parameter like a field. In the expression-designer you have a special category called "Parameters". From there you can access your parameters. The syntax is =Parameters![FieldName].Value. In your case for example =Parameters!datastart.Value.

    Additionaly, note that the parameters must be declared in the "Report Data"-window under "Parameters". Its the same window as you use to declare your recordsets, however there is also a special category for parameters. There are also some options for the datatype and if specification of the parameter is mandatory.

    0 讨论(0)
  • 2021-02-13 03:05

    Try this:

    ReportParameter PrmInvoiceNo = new ReportParameter("PrmInvoiceNo");
    PrmInvoiceNo.Values.Add(this.InvNo.ToString());
    this.reportViewer1.LocalReport.SetParameters(PrmInvoiceNo);
    
    0 讨论(0)
提交回复
热议问题