none
ReportViewer SetParameters Problem RRS feed

  • Question

  • Hi All,

     

    I got my reportviewer up and running, the only problem in the way of deploying my program is the bit of setting the parameters.

    A little sample code:

     

    Code Block

    Microsoft.Reporting.WebForms.ReportParameter[] parameters = new Microsoft.Reporting.WebForms.ReportParameter[1];

    parameters[0] = new Microsoft.Reporting.WebForms.ReportParameter(name, value);

    ReportViewer1.ServerReport.SetParameters(parameters);

     

     

     

    This works fine until i want a parameter to be NULL, i set the parameter to AllowNull in the report and trying to leave it out of the parameters array, didnt work.

    I tried

    Code Block
    parameters[0] = new Microsoft.Reporting.WebForms.ReportParameter(name);

     

     

     

    Hoping it would be NULL on server side, didnt work. Im quite desperate now...

     

    Anyone knows the solution?

     

    Thanks in Advance,

     

    Figa

     

     

    Edit:

     

    The error i get:

  • The 'name' parameter is missing a value
  • I get this error when im adding the parameter in the array, but do not set a  value.

    When i dont add the parameter i get a popup with the text 'Value cannot be null'...

Friday, October 19, 2007 1:26 PM

Answers

  • I found the solution:

    Pseudo Code snippet

     

    Code Block

    Microsoft.Reporting.WebForms.ReportParameter[] parameters = new Microsoft.Reporting.WebForms.ReportParameter[ParameterAmount];

     

    foreach(parameter)

    {

    parameter.name = thename;

    parameter.value = thevalue;

    parameters[i] = parameter

    }

     

    ReportViewer1.ServerReport.SetParameters(parameters)

    ReportViewer1.ServerReport.Refresh();

     

     

     

    Hope this helps someone,

    Until next time Wink

     

    Friday, October 19, 2007 2:52 PM

All replies

  • I found the solution:

    Pseudo Code snippet

     

    Code Block

    Microsoft.Reporting.WebForms.ReportParameter[] parameters = new Microsoft.Reporting.WebForms.ReportParameter[ParameterAmount];

     

    foreach(parameter)

    {

    parameter.name = thename;

    parameter.value = thevalue;

    parameters[i] = parameter

    }

     

    ReportViewer1.ServerReport.SetParameters(parameters)

    ReportViewer1.ServerReport.Refresh();

     

     

     

    Hope this helps someone,

    Until next time Wink

     

    Friday, October 19, 2007 2:52 PM
  • Hehe here i am again Big Smile

     

    Reply on above post:

    Leave out if you want to use NULL

    parameter.value = thevalue;

     

     

    Next problem, when i use the normal values and click view a second time the reportviewer/server remembers the values from the first view. I want these to be cleared, any way of doing this?

     

    Thanks again (Probably will answer myself againSmile)

    Friday, October 19, 2007 3:37 PM