Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi every body i read about Export Datagridview to Crystal Report in C# Windows it works fine but all of these have Crystal Reportviewer in the same form and bind data to crystalreport using that code

C#
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("proname", typeof(string));
dt.Columns.Add("price", typeof(decimal));
dt.Columns.Add("quantity", typeof(decimal));
dt.Columns.Add("total", typeof(decimal));
foreach (DataGridViewRow dgv in dataGridView1.Rows)
{
dt.Rows.Add(dgv.Cells[1].Value, dgv.Cells[4].Value, dgv.Cells[6].Value, dgv.Cells[7].Value);
}
ds.Tables.Add(dt);
ds.WriteXmlSchema("Print.xml");
this.dataGridView1.DataSource = null;
this.dataGridView1.Rows.Clear();
txtamountnumber.Text = "";
CrystalReportSells cr = new CrystalReportSells();
cr.SetDataSource(ds);



how can i bind the data to crystal report viewer in another form in button click not in the same form
Posted

1 solution

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