Loading reportviewer through an object

2

I'm using the Report Viewer to do some reporting, but I'm not able to access some data from my object. instead of making a direct connection to the database I pass a DataTable as a reference, and already in the ReportViewer I add a DataSet Object. This is the following structure used:

class Produto{
    public int Codigo{get;set}
    public string NomeProduto {get;set;}
    public Categoria Cat {get;set;}
}

class Categoria{
    public int Codigo{get;set}
    public string NomeCategoria{get;set;}
}

In ReportViewer I have normal access to Code and ProductName but I can not access the items of my Category object ... I use the expression =Fields!Codigo.Value to retrieve the Product code and in Expression Fields an option appears with Category First(Fields!Categoria.Value, "Data") but even if I put this it does not load anything, I wanted to know how it is possible to load the name of the Category, for example First(Fields!(Categoria.NomeCategoria).Value, "Data")

    
asked by anonymous 12.08.2017 / 15:38

1 answer

0

You just associate the DataSet with your Table in the Report (The attributes must have the same name), and pass the list modelList to DataSource :

LocalReport relatorio = new LocalReport();
relatorio.DataSources.Add(new ReportDataSource("DSTituloProjetado", modelList));
    
20.12.2017 / 17:01