Krishna Mohan
Krishna Mohan

Reputation: 315

how to pass textbox value to crystal report?

i want to pass the text box value to crystal report . i have added one parameter named "JoiningDate" in parameters fields and that parameter field i have added in .rpt files {?JoiningDate}. how to add my parameter in the code behind.

ReportDocument crystalReport = new ReportDocument();
    crystalReport.Load(Server.MapPath("~/ExperienceLetter.rpt"));
    DataSet dsCustomers = GetData("select top 1 * from employees");
    crystalReport.SetDataSource(dsCustomers);
    CrystalReportViewer1.ReportSource = crystalReport; 
    string dateValue = txtJoiningDate.Text;
    crystalReport.SetParameterValue("@JoiningDate", dateValue);         

Upvotes: 0

Views: 4808

Answers (2)

user4340666
user4340666

Reputation: 1473

    TextObject text = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text1"];
text.Text = textBox1.Text;

here is simple example explaining it.

Upvotes: 1

Jafrul Sadek Nabil
Jafrul Sadek Nabil

Reputation: 85

if you just want to show text value , i sagest use the code below .

TextObject txtObj = (TextObject)crystalReport.ReportDefinition.Sections["GroupHeaderSection1"].ReportObjects["Text10"];

but for some logic or calculations use model binding .. Visit: http://tektutorialshub.com/how-to-create-crystal-report-using-visual-studio/

Upvotes: 1

Related Questions