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

安稳与你 提交于 2019-12-17 16:50:29

问题


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...


回答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




回答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);



回答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();



回答4:


following method worked for me i used vb.net2010

1: In Visual Studio 2010, open your .rdlc file, and open “Report Data” window (If you can not see this window, go to View menu to open it);

2: Right click the “Parameters” node, and add a new Parameter, ie: named it “startdate“;

3: In your .rdlc file, add a textbox, named it tbContent, and set its filed express to :

=Parameters!startdate.Value

4: Go to your Form file which include your reporterview control, and add the following code:

  Dim rptparameter As ReportParameter
  rptparameter = New ReportParameter("content", txt_startdate.Text)
  rv_param.LocalReport.SetParameters(New ReportParameter() {rptparameter})
  rv_param.LocalReport.Refresh()


来源:https://stackoverflow.com/questions/6302459/how-to-pass-textbox-combobox-value-to-rdlc-report-text-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!