Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to display the datagridview data to crystal reports without ado.net connections. That Means Empty Crystal Reports Don't having Columns Drag and drop.. But I want Datagridview data to Report.. Thanks In Advance..
Posted

 
Share this answer
 
I hope you are familiar with adding data to your report from a DataSet. So what you have to do is bind your datagridview data to your DataSet like this

C#
DataTable dt = new DataTable();

            dt.Columns.Add("Column1", typeof(string));
            dt.Columns.Add("Column2", typeof(string));
            dt.Columns.Add("Column3", typeof(double));

            DataSetReport ds = new DataSetReport(); //DataSet

            foreach (DataGridViewRow dgv in datagridview1.Rows)
            {
                dt.Rows.Add(dgv.Cells["Col1"].Value.ToString(), dgv.Cells["Col2"].Value.ToString(), double.Parse(dgv.Cells["Col3"].Value.ToString()));

            }
ds.Tables[0].Merge(dt);
 
Share this answer
 
v2

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