alaa

alaa

  • NA
  • 166
  • 84.9k

Export Datagridview to Crystal Report in C# Windows

May 25 2015 7:31 AM
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
 
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 

Answers (3)