This is a migrated thread and some comments may be shown as answers.

How to fill a subreports datasource with a list of objects?

1 Answer 213 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Otavio
Top achievements
Rank 1
Otavio asked on 27 Jul 2011, 11:16 PM
Hi,

I need show data of three different datasources in the same report. I'm trying to use a subreport but I donĀ“t have success. 

public class ViagemInfo
{
    public int IDEmpresa { get; set; }
    public int AnoViagem { get; set; }
    public int IDViagem { get; set; }
    public int IDConta { get; set; }
    public List<MotoristaViagemInfo> MotoristasViagem { get; set; }
}
 
public class MotoristaViagemInfo
{
    public int IDMotorista { get; set; }
    public int Nome { get; set; }
}
     
private void LoadData(int IdEmpresa, int AnoViagem, int IdViagem)
{
    ViagemInfo viagemInfo;
    try
    {
        using (PedidoProxy.Pedido svcProxy = new PedidoProxy.Pedido())
        {
            //load the ViagemInfo with a List<MotoristaViagemInfo>
            viagemInfo = svcProxy.ObterViagemDetalhada(IdEmpresa);
        }
        CertificadoViagem reportCertificado = new CertificadoViagem();
        reportCertificado.ReportParameters["IdEmpresa"].Value = IdEmpresa;
        reportCertificado.DataSource = viagemInfo;
    }
    catch
    {
        throw;
    }
}

How am I set a datasource of subreport with a MotoristasViagem property of viagemInfo?

1 Answer, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 28 Jul 2011, 03:28 PM
Hi Otavio,

 

In order to use a nested collection as subreport datasource our suggestion is to use bindings. Just set binding to the subreport's ReportSource.DataSource as shown in the following binding:

Property path 

Expression 

 ReportSource.DataSource

 =Fields.MotoristasViagem 

Kind regards,
Peter
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
General Discussions
Asked by
Otavio
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or