Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hello!

I why is all the values in my table here the same. It looks like this:
<img src='http://bildr.no/thumb/1206258.jpeg' alt='1206258' />

I want this:
<img src='http://bildr.no/thumb/1206259.jpeg' alt='1206259' />

I have a report1 with list, list contains subreport and textbox. Report1 have dataset table1 which has one field, id. Used in textbox in list.

Subreport contains an table which is set to a dataset which contains Table2. Table2 is created and set in LocalReport_SubreportProcessing, and contains 1 value which is generated in this method.

St


C#
namespace subreportTest2012
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int i = 0;
            while (i < 10)
            {
                this.DoseStudioDataSet.DataTable2.Rows.Add(i);
                i++;
            }

            this.reportViewer1.LocalReport.SubreportProcessing += LocalReport_SubreportProcessing;

            this.reportViewer1.RefreshReport();



        }
        int subReport = 0;
        void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WinForms.SubreportProcessingEventArgs e)
        {
            subReport++;

            var dt = new DoseStudioDataSet.DataTable1DataTable();
            int t = 0;
            while (t < 5)
            {
                var dr = dt.NewDataTable1Row();
                dr.DataColumn1 = subReport.ToString();
                dr.DataColumn2 = subReport.ToString();
                dr.DataColumn3 = subReport.ToString();
                dr.DataColumn4 = subReport.ToString();
                dt.Rows.Add(dr);
                t++;

            }



            var bs = new BindingSource();

            bs.DataSource = dt;
            var rds = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", bs);
            e.DataSources.Add(rds);
            
        }
    }
}



but it ends up like this
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900