locked
pass textbox value to crystal report RRS feed

  • Question

  • Hi Team,

    I have written this code but it showing error message as "Cannot implicitly convert type 'CrystalDecisions.CrystalReports.Engine.ReportObject' to 'CrystalDecisions.CrystalReports.Engine.TextObject'. An explicit conversion exists (are you missing a cast? ) please help me with solution.

     

               CrystalReport1 rpt_doc = new CrystalReport1();         
                CrystalDecisions.CrystalReports.Engine.ReportDocument rpt_form;
                CrystalDecisions.CrystalReports.Engine.TextObject T;
                rpt_form = rpt_doc;
                T = rpt_form.ReportDefinition.Sections[0].ReportObjects["Billno"];
                T.Text = Txt_Billno.Text.ToString();
                crystalReportViewer1.ReportSource = rpt_doc;

     

    Thanks in advance.          

    Monday, March 28, 2011 5:05 PM

Answers

  • Just do following for passing parameter to crystal report.

    1. Add a crystal report on your project. (consider report is cr.rpt)

    2.Open crystal report on design mode.

    3. Go to Field explorer window > Then right click on Parameter Field > New

    4. Then give a name of your parameter (consider pText)

    5. Now go to your win form design view

    6. Add a CrystalReportViewer control on your form.

    7. Then load your crystal report on your crystal report viewer using following code

    cr crystalreport = new cr();
    crystalreport.SetParameterValue("pText", "your parameter value");
    crystalReportViewer1.ReportSource = crystalreport;
    

    just check following link for getting sample win application project on it.

    download Sample


    Hasibul Haque, MCPD http://blog.e-rains.com
    Wednesday, March 30, 2011 4:15 AM

All replies

  • I think you can use parameter on your crystal report to pass Txt_BillNo.Text.

    Just do following for adding parameter on your crystal report.

    1. Add a parameter on your crystal report.

    2. Pass parameter value from UI.

    consider your parameter name is pBillNo

    passing parameter to Crystal Report

     

    rpt_doc.SetParameterValue("pBillNo",Txt_BillNo.Text);
    
    Hope it will help you.

     


    Hasibul Haque, MCPD http://blog.e-rains.com
    Tuesday, March 29, 2011 3:09 AM
  • Hi Hasibul,

    I am very new to dot net could you please share some sample code, It will be very help ful for me ...

     

    Thanks,

    Kumar soundarajan

    Tuesday, March 29, 2011 4:21 PM
  • Just do following for passing parameter to crystal report.

    1. Add a crystal report on your project. (consider report is cr.rpt)

    2.Open crystal report on design mode.

    3. Go to Field explorer window > Then right click on Parameter Field > New

    4. Then give a name of your parameter (consider pText)

    5. Now go to your win form design view

    6. Add a CrystalReportViewer control on your form.

    7. Then load your crystal report on your crystal report viewer using following code

    cr crystalreport = new cr();
    crystalreport.SetParameterValue("pText", "your parameter value");
    crystalReportViewer1.ReportSource = crystalreport;
    

    just check following link for getting sample win application project on it.

    download Sample


    Hasibul Haque, MCPD http://blog.e-rains.com
    Wednesday, March 30, 2011 4:15 AM