How to make a table of purchased items on crystal report from the dataset dynamically with c#.net? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to make a table of purchased items on crystal report from the dataset dynamically with c#.net?

i am making a project and adding purchased product details one by one in the dataset dynamically. so aftet the addition of data it will be show on the report page. please consider!

1st Oct 2018, 1:04 PM
Shubham Sharma
Shubham Sharma - avatar
1 Answer
+ 1
once C# Crystal Reports designer part is over . Next part is to create data for the Crystal Reports . For that you have to create a Data Table through programmatically and add data to dataset1. Select the default form (Form1.cs) you created in C# and drag a button and a CrystalReportViewer control to your form . Copy and paste the following source code and run your C# project. using System; using System.Windows.Forms; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.Data; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { DataSet1 ds = new DataSet1(); DataTable t = ds.Tables.Add("Items"); t.Columns.Add("id", Type.GetType("System.Int32")); t.Columns.Add("Item", Type.GetType("System.String")); DataRow r ; int i = 0; for (i = 0; i <= 9; i++) { r = t.NewRow(); r["id"] = i; r["Item"] = "Item" + i; t.Rows.Add(r); } CrystalReport1 objRpt = new CrystalReport1(); objRpt.SetDataSource(ds.Tables[1]); crystalReportViewer1.ReportSource = objRpt; crystalReportViewer1.Refresh(); } } }
12th May 2020, 5:48 AM
Divya Peddapalyam
Divya Peddapalyam - avatar