Jak dodac dane do subreport

0

Witam,
mam problem z wyświetleniem danych w reportviewer :/ mam 2 Report.rdlc w pierwszym Report1.rdlc mam dołączony subreport który ma wyświetlić dane z Report2.rdlc, ale niestety dane z Report2.rdlc nie chcą się wyświeltić :/ dane jakie maja się wyświetlić to w Report1.rdlc wyświetlam name z obiektu Parent a w Report2.rdlc wyswietlan nameCH1, nameCH2, nameCH2 z obiektu Children.

 public partial class Form1 : Form
    {
        List<Child> chlist = new List<Child>();
        public Form1()
        {
            InitializeComponent();
            chlist.Add(new Child("ch1", "ch11", "ch111"));
            chlist.Add(new Child("ch12", "ch112", "ch1112"));
            chlist.Add(new Child("ch13", "ch113", "ch1113"));
            chlist.Add(new Child("ch14", "ch114", "ch1114"));

         SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
               }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
    
            ParentBindingSource.DataSource = new Parent();
            this.reportViewer1.RefreshReport();
        }


        void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
        {
            if (e.ReportPath == "Report2")
            {              
                e.DataSources.Add(new ReportDataSource("Report2", chl));
            }
        }
    } 
0

Jednak sobie poradziłem z tym :)
Jeśli ktoś będzie miał z tym problem to podaje link do tutoriala
http://blog.adsystems.com.br/2009/04/10/tutorial-c-relatorios-master-detail-com-reportviewer/

0

nie wiem czy się bawi, ale coś takiego:

        List<Child> chlist = new List<Child>();

            chlist.Add(new Child("ch1", "ch11", "ch111"));
            chlist.Add(new Child("ch12", "ch112", "ch1112"));
            chlist.Add(new Child("ch13", "ch113", "ch1113"));
            chlist.Add(new Child("ch14", "ch114", "ch1114"));

możesz zapisać jako:

List<Child> chlist = new List<Child> {
                  new Child("ch1", "ch11", "ch111"),
                  new Child("ch12", "ch112", "ch1112"),
                  new Child("ch13", "ch113", "ch1113"),
                  new Child("ch14", "ch114", "ch1114")
};

1 użytkowników online, w tym zalogowanych: 0, gości: 1