Click here to Skip to main content
15,906,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi how to pass crystal parameters from aspx to crystall report..??
and parameter should be placed in textbox and when clicking on button it should display details related to that parameter in crystal report..?


can anyone suggest me how to do that..
thanks in advance..
Posted

hai
Set the parameter value in crystall report

C#
CrystalReport1 report = new CrystalReport1();
           report.SetParameterValue("paramname",textbox1.text)
 
Share this answer
 
Comments
ythisbug 25-Feb-12 2:07am    
hai adersh

here is my coding for botton click.and issue is details are not showing when i click search button..

protected void imgbtnSearch_Click(object sender, ImageClickEventArgs e)
{
try
{
con.Open();
string TID = "";
TID = txtTestCase.Text;
cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;

cmd.CommandText = "usp_SearchTestDetails";
cmd.Connection = con;

SqlParameter pTestCase = new SqlParameter("@TID", SqlDbType.VarChar, 50);
pTestCase.Value = TID;
cmd.Parameters.Add(pTestCase);


da = new SqlDataAdapter(cmd);
dt.Clear();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
ReportDocument RptDoc = new ReportDocument();

RptDoc.Load(Server.MapPath("~/Admin/CrystalReport5.rpt"));
RptDoc.SetDataSource(dt);
CrystalReportViewer1.ReportSource = RptDoc;
RptDoc.SetParameterValue("TID", txtTestCase.Text);
CrystalReportViewer1.DataBind();
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
cmd.Dispose();
con.Close();
}
}


can u solve this..wres da error..??
First u set the parameter then set the report datasource

C#
RptDoc.SetParameterValue("TID", txtTestCase.Text);

C#
CrystalReportViewer1.ReportSource = RptDoc;
 
Share this answer
 
Comments
ythisbug 25-Feb-12 6:25am    
ok i wil try thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900