Teju MB
Teju MB

Reputation: 1383

how to display Textbox values in the crystal reports?

i have a text box in the front end i want to display this textBox value along with my data table in CRYSTAL REPORT VIEWER. I have displayed data table value successfully , but found some hurdles to display textBox values. I am using Web Application(c#). Pls Help..

Thanks in Advance..

this is my code-

  protected void btnExport_Click(object sender, EventArgs e)
{
    ReportDocument rdt = new ReportDocument();
    EmpDetail emp1 = new EmpDetail();
    DataTable dt = new DataTable();
    dt.TableName = "EmpDataTable";
    dt = putEmployeeDetails();
    emp1.Tables[0].Merge(dt);
    rdt.Load(Server.MapPath("Emp.rpt"));
    rdt.SetDataSource(emp1);
    CrystalDecisions.CrystalReports.Engine.ReportDocument doc=rdt;
    doc.DataDefinition.FormulaFields["display1"].Text = "sdfsdf";
    CrystalReportViewer1.ReportSource = rdt;
}

for this am getting error at doc.DataDefinition.FormulaFields["display1"].Text = "sdfsdf"; as "Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))"

Upvotes: 0

Views: 9905

Answers (3)

Aqeel Ahmed
Aqeel Ahmed

Reputation: 26

write your query and everything and fill in Dataset.

Dim SPATH As String = "C:\Documents and Settings\Aqeel\My Documents\Visual Studio 2008\Projects\PHARMA\PHARMA"
SPATH += "\Combinedrp.rpt"
RPT.Load(SPATH)
RPT.SetDataSource(DS2)
Dim firstName = RPT.ParameterFields("@dt1")
firstName.CurrentValues.AddValue(TextBox1.Text)
firstName.HasCurrentValue = True

Dim lastName = RPT.ParameterFields("@dt2")
lastName.CurrentValues.AddValue(TextBox2.Text)
lastName.HasCurrentValue = True
CrystalReportViewer1.ReportSource = RPT

Upvotes: 1

Lee Tickett
Lee Tickett

Reputation: 6027

You can always create parameters in your crystal report then pass your text to those parameters.

Upvotes: 0

Ashwini Verma
Ashwini Verma

Reputation: 7525

you can do something like this:

CrystalDecisions.CrystalReports.Engine.ReportDocument doc=load your document;
doc.DataDefinition.FormulaFields["formulafieldname"].Text = "'your text here";

please go through this link:textbox to Crystal Report

and also visit here for more about Crystal report:Crystal Reports in ASP.NET

Upvotes: 1

Related Questions