我正在尝试在我的水晶报告中显示一个文本框,作为对我已经开始的内容的修改。我的数据表已经在工作,我想将文本从文本框直接传输到水晶报表 unboundstring。我有问题。这是我的代码示例。你能帮我么。我对这条线有特定的问题
((TextObject)objRpt.Section2.ReportObjects["@UnboundString1"]).Text = TextBox1.text;
谢谢。
这是错误:无法将“CrystalDecisions.CrystalReports.Engine.FieldObject”类型的对象转换为“CrystalDecisions.CrystalReports.Engine.TextObject”类型。
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();
}