How to pass textbox/Combobox value to rdlc report text field?

41,947

Solution 1

One way would be to setup a parameter for each of the fields you want to bring in and set the value of the parameter to whatever you want in your C# app. In the report you would then set the value of each text box to be the parameter and it should work just fine.

Or if you are using RDLC files (which you are) you could put your data into a dataset and pass that to the report and then have each field in the report a column in the dataset

Solution 2

Set the parameters using LocalReport property in the Report Viewer

C# Code :

ReportParameterCollection reportParameters = new ReportParameterCollection();
reportParameters.Add(new ReportParameter("ParameterName", "Value"));
this.reportViewer.LocalReport.SetParameters(reportParameters);

Solution 3

1) Create parameter in RDLC Report.
2) Place the parameter Where you want in the RDLC Input Textbox property.
3) Type the below code in Reprot.cs page.
4) Passing the parameter value where you redirect the Report page.

ReportParameter[] parms = new ReportParameter[n];
parms[0] = new ReportParameter("param_name", textbox(n-1).text);
parms[1] = new ReportParameter("param_course", textbox(n).text);
this.reportViewer1.LocalReport.SetParameters(parms);
this.reportViewer1.RefreshReport();
Share:
41,947
Sagotharan
Author by

Sagotharan

I'm developer & Designer in Company Called M Cubic Software Pvt Ltd, Chennai. See my Portfolio in www.DigitalSagotharan.com. Here you can find my works & web freebies. DigitalSagothan.blogspot.com has more number of psd Templates, Photoshop ASL files, Actions, Psd Websites and some tutorials.

Updated on October 17, 2020

Comments

  • Sagotharan
    Sagotharan over 3 years

    c#, mysql in my project.

    In that i create a rdlc report. I dont know to pass winform textbox value to rdlc report text field.

    I googled and try some set of code. but cant get that.

    If you worked in report. please help me.

    My requirement is,..

    I am doing college project. In that they asked bonafide certificate. So i create a winform With reportviwer, name, course, year, semester, academic year, purpose textboxs and one button. Click the button when the textboxes are filled. those text values want to pass the record textboxes.

    Is it possible any way.

    my report...

    enter image description here

  • sohaiby
    sohaiby almost 10 years
    for everyone searching for ReportParameterCollection namespace, its using Microsoft.Reporting.WinForms;
  • Julian50
    Julian50 about 9 years
    Is there an other way without STRING name parameter ? I mean Using autocompletion ? If I change the name of the parameter, build will not raise error...