0

Morning all,

Using Visual Studio 2012 Ultimate and C#.NET 4.0.

IList<Microsoft.Reporting.WinForms.ReportParameter> param = new List<Microsoft.Reporting.WinForms.ReportParameter>();

param = repsetup.NewReportSetup(
    txtNewPart.Text.ToString(),
    txtBatch.Text.ToString(), 
    txtLocation.Text.ToString(), 
    txtWheel.Text.ToString(), 
    txtGear.Text.ToString(), 
    txtLength.Text.ToString(),
    txtFits.Text.ToString(), 
    txtNewBar.Text.ToString(), 
    txtNewBarNum.Text.ToString(), 
    txtABS.Text.ToString()
);

reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter(param));

When trying to set the report parameters it complains about the list. The list is populated in another table and returns a list.

Error 2 - Argument 1: cannot convert from 'System.Collections.Generic.IList<Microsoft.Reporting.WinForms.ReportParameter>' to 'string'

Also error:

Error 1 - The best overloaded method match for 'Microsoft.Reporting.WinForms.ReportParameter.ReportParameter(string)' has some invalid arguments

How do I use the IList in the SetParameters method?

Many Thanks

Here's the NewReportSetup method:

public IList<Microsoft.Reporting.WinForms.ReportParameter> NewReportSetup(string part, string batch, string locn, string wheel, string gear, string length,
                                string fits, string newbar, string newbarnum, string abs)
{
    IList<Microsoft.Reporting.WinForms.ReportParameter> parameters = new List<Microsoft.Reporting.WinForms.ReportParameter>();
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramPart", part));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramBatch", batch));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramLocn", locn));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramWheel", wheel));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramGear", gear));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramLength", length));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramABS", abs));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramBuyer", fits));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramBarCode", newbar));
    parameters.Add( new Microsoft.Reporting.WinForms.ReportParameter("paramBartxt", newbarnum));
    return parameters;
}
davmos
  • 9,324
  • 4
  • 40
  • 43
lemunk
  • 2,616
  • 12
  • 57
  • 87

1 Answers1

1

The Report.SetParameters method requires an IEnumerable<ReportParameter>:

In other words send your list of report parameters to this method, not an instance of a ReportParameter (which you're trying to create from your list):

reportViewer1.LocalReport.SetParameters(param);
devdigital
  • 34,151
  • 9
  • 98
  • 120
  • many thanks for the reply, not entirly sure What you mean though, You a got a quick Snippet i could look at? – lemunk Nov 16 '12 at 12:44
  • The snippet is reportViewer1.LocalReport.SetParameters(param); Change your last line to that. – devdigital Nov 16 '12 at 13:19