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

Bind ReportViewer dynamically

1 Answer 366 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lachezar
Top achievements
Rank 1
Lachezar asked on 30 Sep 2015, 08:19 AM

Hi all. I have a problem and don't know how to fix. I add a reportviewer control to aspx and try to set the ReportSource from code behind. The report is rendering on page, but unfortunately there is no content. When debugging i see that the ReportSource of report viewer is the same, which i bind, but no table shows on screen. I'm creating the Report object programmatically. If load report, created from standalone Report Designer there is no problem. 
 This is the custom object I've tried to bind:
"[DataObject]
public class ReportSource
{
    [DataObjectMethod(DataObjectMethodType.Select)]
    public IList<Source> GetData()
    {
        var result = new List<Source>();
        var data = ActiveTradesCache.GetActiveTradeData();

        foreach (var item in data)
        {
            result.Add(new Source() { Rate = item.OrderRate });
        }


        return result;
        //trgOpendDeals.DataSource = new Object[0];
        //trgOpendDeals.MasterTableView.VirtualItemCount = 0;
        //trgOpendDeals.DataBind();
    }

}

public class Source
{
    public double Rate { get; set; }
}

"
 And the fill source method, which is in Page_Load event:
 "
Telerik.Reporting.ObjectDataSource objectDataSource = new Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = typeof(ReportSource);
objectDataSource.DataMember = "GetData";
Telerik.Reporting.Report report = new Telerik.Reporting.Report();
report.DataSource = objectDataSource;
Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
rvOpenDeals.ReportSource = reportSource;
// Calling the RefreshReport method in case this is a WinForms application.
rvOpenDeals.RefreshReport();


reportSource.ReportDocument = report;

"

 

Best regards,

Lachezar

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 02 Oct 2015, 02:42 PM
Hi Lachezar,

Please check my reply on your question in the How do I start Report Designer in VS 2013? forum thread.

I will appreciate it of we continue the discussion in one of both threads in order to keep a better track on the exchanged information. Also you can open a support ticket, where the system allows ZIP attachments to share your code.


Thank you for your understanding.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Lachezar
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or