c# - How to bind objects correctly with reportviewer? -


I have recently been studying Report Viewer and I have a problem I can not solve ...

I am trying to bind data from a collection of objects where each object contains a collection of child objects (rows) how can this be done? Below are the pieces of code I have (somedata header is a collection of objects).

The Windows form with ReportViewer control is the following:

  reportViewer1.ProcessingMode = Local ProcessingMode; ReportViewer1.LocalReport.LoadReportDefinition (GetReport ()); ReportViewer1.LocalReport.DataSources.Clear (); Var dataSourcesNames = GetDataSourceNames (); Var header source = new ReportDataSource (data source name [0], somedata); ReportViewer1.LocalReport.DataSources.Add (headerSource); ReportViewer1.RefreshReport ();   

Header object:

  public class report header {read string id; Read-only list & lt; ReportRow & gt; Rows; Public Report Data (Header H) {this.id = h.Id; Line = new list & lt; ReportRow & gt; (); Foreign (HOROBZ O) in Rows (Rows.Update (New Reporter (O));}} Public String ID {get {return id;}} Public listing & lt; ReportRow & gt; Rows {return lines}}} < / Code>  

Receive line objects:

  public class ReportRow {readable decimal amount; read only string type; read string code; public report data (ROBOBS R) {sum = r.Sum; Type = R; Code = r.Code;} Jan Malav's par value {Received {Refund amount;}} Public string type {get {return type;}} Public string code {get {return code;}}}   

I created a report Header has all the attributes and a list that should include all the reporter but it does not work, the only solution was to create two separate collections, ReportHard Collections and Reporter collections, and then separate them as below:

  va R headerSource = new ReportDataSource (Datasource name [0], somedata); reportViewer1.LocalReport.DataSources.Add (headerSource); Var rowSource = New ReportDataSource (Data Source Name [1], somedata.Rows); ReportViewer1.LocalReport.DataSources.Add (RowSource);   

With this solution, I will need to make some kind of relationship between the collection ..? So please help (note that I have simplified things for my question)

If I Do you really understand your question, can you just pass the header to a boolean object and then do a function for your field = field in your res .cdlc text box! Header If you have all your areas layered and hidden, then you may have a header and data in the same column.

Comments