how to display Textbox values in the crystal reports?

0

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))"

asp.net
crystal-reports
asked on Stack Overflow Mar 29, 2012 by Teju MB • edited Mar 29, 2012 by Teju MB

3 Answers

1

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

answered on Stack Overflow Mar 29, 2012 by Ashwini Verma
1

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
answered on Stack Overflow Jul 7, 2012 by Aqeel Ahmed • edited Jul 5, 2013 by Kreiri
0

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

answered on Stack Overflow Mar 29, 2012 by Lee Tickett

User contributions licensed under CC BY-SA 3.0