locked
ReportParameter problem... help pls... RRS feed

  • Question

  • User-775831949 posted

    I havea ReportViewer linked to a Report1.rdlc
    In the .aspx I have a datasource like this: Select * from Data
    One of the field is called City.

    Now this report renders nicely without error.

    Ok then I want to create a Report Parameter.

    Finally it leads to error like this

    • An error occurred during local report processing.
      • The definition of the report 'Main Report' is invalid.
        • A Value expression used for the report parameter ‘City’ refers to a field. Fields cannot be used in report parameter expressions.

    Please help to review what is wrong/missing in my steps:-

    (1) I change the datasource to: Select * from Data where City = @City
    (2) In Report.rdlc page, right click top left corner and Select Report Parameter
    (3) In Name box typed City, DataType selected String, Prompt: Leave it as is "Report_Parameter_0"
    (4) In Available section (the area which I believe I may have made it wongly)
    Label : =First(Fields!City.Value, "SalesDataSet_Data")
    Value: =First(Fields!City.Value, "SalesDataSet_Data")
    (5) DefaultValues: Null box is checked

     

    Pls help... how should I set the answers to (4) above in particular, and any other step I have missed or made wrongly?

    Thanks

    Saturday, December 25, 2010 11:30 AM

Answers

  • User1471008070 posted

    Hi hkbeer,

    It is not the correct method in your step 4, in reporting services we could set parameter's default value and availabe value in this way, howerver it is different in local report, you could give a static value or a dynamical value for the parameter. If the parameter is a static parameter, just type in the following sample code:

    private void SetReportParameters() {
       ReportParameter p = new 
          ReportParameter("paraName", "paraValue");
       this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p });
    }
    


    If you want to pass a dynamical parameter value to the parameter, you could add some Web controls to the web application, the pass control's value to the parameter dynamically. Just like below sample:

    ReportParameter p = new 
          ReportParameter("ShowDescriptions", checkBox1.Checked.ToString());
       this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p });
    


     

    For more information about the LocalReport.SetParameters Method, please see: http://msdn.microsoft.com/en-us/library/ms252146(v=VS.90).aspx 

    Thanks,
    Challen Fu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 27, 2010 2:04 AM

All replies

  • User-775831949 posted

    ok In (4) I created another datasource to select unqiue City and use that as data for Label and Value and get same error...

    Maybe the forumla is in error ?

    Pls help.. 

    Saturday, December 25, 2010 9:05 PM
  • User1471008070 posted

    Hi hkbeer,

    It is not the correct method in your step 4, in reporting services we could set parameter's default value and availabe value in this way, howerver it is different in local report, you could give a static value or a dynamical value for the parameter. If the parameter is a static parameter, just type in the following sample code:

    private void SetReportParameters() {
       ReportParameter p = new 
          ReportParameter("paraName", "paraValue");
       this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p });
    }
    


    If you want to pass a dynamical parameter value to the parameter, you could add some Web controls to the web application, the pass control's value to the parameter dynamically. Just like below sample:

    ReportParameter p = new 
          ReportParameter("ShowDescriptions", checkBox1.Checked.ToString());
       this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p });
    


     

    For more information about the LocalReport.SetParameters Method, please see: http://msdn.microsoft.com/en-us/library/ms252146(v=VS.90).aspx 

    Thanks,
    Challen Fu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 27, 2010 2:04 AM