How to get data of datagridview in Crystal Report in C#

14,006

Dear Saima Follow the given link. What you are missing is Table in design mode. Crystal report in design mode need to have a table that contains exactly the same field in your dataset Then you can use your code and it will work well

Hope this helps

Follow this Link

Share:
14,006
Saima Maheen
Author by

Saima Maheen

I am new Programmer.........!

Updated on June 14, 2022

Comments

  • Saima Maheen
    Saima Maheen almost 2 years

    I have a Window Form in C#. i want that when i click get report the exact data of datagridview also show in crystal report viewer.

                DataTable dt = new DataTable();
                DataSet ds = new DataSet();
    
                dt = dataGridView1.DataSource as DataTable;
    
                ds.Tables.Add(dt);
    
                CrystalReport2 cos = new CrystalReport2();
    
                cos.SetDataSource(ds);
    
                crystalReportViewer1.ReportSource = cos;
    

    enter image description here

    enter image description here

  • Noel Widmer
    Noel Widmer over 6 years
    Can you elaborate on your answer? Posting a piece of code without any text is often not very helpful.