C# 2015 winform datagrid view selected rows to rdlc report
<p>I am novice to windows application and C#. I am using <code>C# 2015</code> for a <code>windows application</code> with <code>MS-Access 2007</code> database.</p>

<p>I have completed CRUD operations using form and display that records in a <code>datagridview</code>, seems working fine. </p>

<p>Now, what I want is display the selected <code>rows</code> of <code>gridview</code> into a report and print it. Also I don't want them to be display as a table but a form for each records. So that if 3 rows are selected then there will be 3 pages to be printed for each row. </p>

<p>The codes I have done are as below: </p>

<p><strong>customer.cs</strong> </p>

<pre><code>namespace bolt
{
    class customer
    {
        public int? id { get; set; }
        public string firstName { get; set; }
        public string middleName { get; set; }
        public string lastName { get; set; }
        public string panNo { get; set; }
        public string email { get; set; }
        public string mobile { get; set; }
        public string address { get; set; }
        public int dptype { get; set; }
        public string benificiaryId { get; set; }
        public string bankName { get; set; }
        public string bankBranch { get; set; }
        public string bankAccountNo { get; set; }

        customer(int? id = null, string firstName = null, string middleName = null, string lastName = null,
            string panNo = null, string email = null, string mobile = null, string address = null, int dptype = 1,
            string benificiaryId = null, string bankName = null, string bankBranch = null, string bankAccountNo = null
            )
        {
            this.id = null;
            this.firstName = firstName;
            this.middleName = middleName;
            this.lastName = lastName;
            this.panNo = panNo;
            this.email = email;
            this.mobile = mobile;
            this.address = address;
            this.dptype = dptype;
            this.benificiaryId = benificiaryId;
            this.bankName = bankName;
            this.bankBranch = bankBranch;
            this.bankAccountNo = bankAccountNo;
        }

        public customer()
        {
        }
    }
}
</code></pre>

<p>Added a form <code>frmReport</code> and <code>reportviewer</code> inside that. </p>

<p>Added a form <code>frmCustomer</code> which contains <code>datagridview</code>. </p>

<p>Added a <code>rdlc</code> report <code>rptBolt.rdlc</code>, I have not added any control inside it. </p>

<p>In <code>frmCustomer</code>, I have a print button. On clicking it the following code</p>

<pre><code>private void btnPrint_Click(object sender, EventArgs e)
{
    List&lt;customer&gt; lstCustomer = new List&lt;customer&gt;();


    foreach(DataGridViewRow row in dgCustomers.SelectedRows)
    {
        customer c = new customer();
        c.id = Convert.ToInt32(row.Cells[dgCustomers.Columns["Id"].Index].Value);

        lstCustomer.Add(c);
    }

    frmReport r = new frmReport();
    r.Show();
    ReportViewer v = r.Controls.Find("reportViewer1", true).FirstOrDefault() as ReportViewer;
    ReportDataSource dataset = new ReportDataSource("boltReport", lstCustomer);
    v.LocalReport.ReportEmbeddedResource = "bolt.rptBolt.rdlc";
    v.LocalReport.DataSources.Clear();
    v.LocalReport.DataSources.Add(dataset);
    v.LocalReport.Refresh();
    dataset.Value = lstCustomer;

    v.LocalReport.Refresh();

    this.Hide();
}
</code></pre>

<p>I have gone throw many tutorials but each of them are using report wizard and dataset that are directly connected to database, in my case I am using a list. </p>

<p>Let me know if am I on the wrong path or what should I do for it? You may provide answer or at least a link that I may get what I want.</p>