Ravindra Walde

Ravindra Walde

  • NA
  • 206
  • 3.3k

Pass value of text box to crystal report using parameter

May 19 2015 8:53 AM
Hello Everyone,
 
I am Try to pass text box values to crystal report in asp.net.
but it will not fount parameter in my code. it will show popup parameter dialog box window to get value for crystal report.
Below is my Source code for parameter Passing :
 
ReportDocument reportDocument = new ReportDocument();
ParameterFields paramFields = new ParameterFields();
ParameterField paramField = new ParameterField();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "@Name";
paramDiscreteValue.Value = TextBox1.Text.ToString();
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
reportDocument.Load(Server.MapPath("CrystalReport1.rpt"));
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
string sql = "select * from CustomerDetails";
OdbcCommand cmd = new OdbcCommand(sql, conn);
OdbcDataAdapter dscmd = new OdbcDataAdapter(cmd);
DataTable datatable = new DataTable();
dscmd.Fill(datatable);
conn.Close();
reportDocument.SetDataSource(datatable);
CrystalReportViewer1.ReportSource = reportDocument;
 
 
 
 
 If anybody Knows please help me..
 
 
 
Thanks In Advance. 

Answers (4)