Q: How to pass selected data shown from datagridview pass to CrystalReportViewer I want to create a print button to show a datagridview values with some labels in form to crystalReportviewer
this's what i did
i've created a report.rdlc that contains dataset from a class
This's how i show my table to dgv
private void btnSelectAll_Click(object sender, EventArgs e)
        {

            if (cmbCategory.Text == "Struk")
            {
                con.Open();
                string query = "SELECT DISTINCT idStruk,Quantity,Price FROM Laporan";
                SqlDataAdapter SDA = new SqlDataAdapter(query, con);
                DataTable dt = new DataTable();
                SDA.Fill(dt);
                dataGridView2.DataSource = dt;
                con.Close();
}
}

This's how i tried to make a button to show dgv to crystalreportviewer tool
public class Orders
        {
            public string idStruk { get; set; }

            public int Quantity { get; set; }

            public int Price { get; set; }
        }




private void btnPrint_Click(object sender, EventArgs e)
        {
            List<Orders> lst = new List<Orders>();
            lst.Clear();

            for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
            {


                Orders orders = new Orders
                {

                    idStruk = dataGridView2.Rows[i].Cells[0].Value.ToString(),
                    Quantity = int.Parse(dataGridView2.Rows[i].Cells[1].Value.ToString()),
                    Price = int.Parse(dataGridView2.Rows[i].Cells[2].Value.ToString()),
                };
                lst.Add(orders);
            }

               rs.Name = "DataSet1";
                rs.Value = lst;

//then idk what to do next and what else i need to show them in Crystalreportviewer tool

            }
        }


A: So you want to make a button, and when the button is clicked, you want to create a new Crystal Report with datagridview as its value ?
You can actually make a dataset (.xsd), and make a table in your dataset. After that you can link your datatable from your dataset as your crystal report datasource.
