Note that there are some explanatory texts on larger screens.

plurals
  1. POTransferring data from a textbox to unboundstring on crystal reports
    text
    copied!<p>I am trying to display a textbox to my crystal report as a modification of what I have started. My datatable is already working and I would like to transfer a text from a textbox directly to crystal report unboundstring. I am having issues. Here's my code sample. Can you please help me. I am having specific issue with this line </p> <pre><code>((TextObject)objRpt.Section2.ReportObjects["@UnboundString1"]).Text = TextBox1.text; </code></pre> <p>Thanks.</p> <p>This is the Error: Unable to cast object of type 'CrystalDecisions.CrystalReports.Engine.FieldObject' to type 'CrystalDecisions.CrystalReports.Engine.TextObject'.</p> <pre><code>protected void Button1_Click(object sender, EventArgs e) { SqlConnection cnn; string connectionString = null; string sql = null; connectionString = "data source=SERVER; initial catalog= DBO ;user id=sa; password= password"; cnn = new SqlConnection(connectionString); cnn.Open(); sql = "select Leave_Type as DataColumn1,Reason as DataColumn2, Date_From as DataColumn4, Date_To as DataColumn5 from Leave_Application where Badge_Number = '" + TextBox1.Text + "'"; SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn); cnn.Close(); DataSet1 ds = new DataSet1(); dscmd.Fill(ds, "DataTable1"); EmployeeLeave objRpt = new EmployeeLeave(); ((TextObject)objRpt.Section2.ReportObjects["@UnboundString1"]).Text = TextBox1.text; objRpt.SetDataSource(ds.Tables[0]); CrystalReportViewer1.ReportSource = objRpt; CrystalReportViewer1.RefreshReport(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload