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

Passing DataSet to ReportViewer

6 Answers 430 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Abhay
Top achievements
Rank 1
Abhay asked on 17 Dec 2010, 10:03 PM
I would like to pass a DataSet to Telerik Report before it is rendered by the ReportViewer. I am using the WPF ReportViewer and my DataSet is returned as a part of WCF service call. Do you have a sample of creating a DataSet outside the report and then setting it either as a property of the Report or any other suggested way of achieving the same?

6 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 21 Dec 2010, 05:52 PM
Hi Abhay,

Our suggestion is to instantiate your report and set the datasource property within the WPF Form's constructor as shown in the following code snippet:

public Window1()
{
    InitializeComponent();
    var report1 = new MyReport();
    report1.DataSource = myDataSet;
    ReportViewer1.Report = report1;
}

Greetings,
Peter
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
Abhay
Top achievements
Rank 1
answered on 22 Dec 2010, 05:22 PM
Thanks for the response. Is there a way to pass DataSet into the ReportViewer through a binding ? We are using MVVM. Otherwise how do I pass the myDataSet to the Window constructor?

0
Abhay
Top achievements
Rank 1
answered on 22 Dec 2010, 09:47 PM
Just to clarify, I wanted to see if we can have it work through binding. For example, if I have a Report created and initialized with the DataSet, I would like to bind it the following way to the ReportViewer in the xaml. (I tried the following, and binding did not seem to get picked up).

         <telerik:ReportViewer Grid.Row="0" x:Name="ReportViewer1" Report="{Binding DataContext.AuditReport, Mode=TwoWay}" />
0
Hrisi
Telerik team
answered on 29 Dec 2010, 04:09 PM
Hello Abhay,

To use binding you should create the View Model first and set it as DataContext for the ReportViewer (or the Form).

Best wishes,
Hrisi
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
Rosbel
Top achievements
Rank 1
answered on 01 Apr 2020, 05:36 AM

 

HI, 

 

 

i was reading this post and i have a question because i can find the way to inser a dataset with the data that i wan to show in the report because of this.

i've pass the uri of the report to the datasource but, where i can put my dataset?

 

 

<body>
    <script runat="server">
        public override void VerifyRenderingInServerForm(Control control)
        {
            // to avoid the server form (<form runat="server"> requirement
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var Datasett =  loaddata();

            var report = new Telerik.Reporting.TypeReportSource() { TypeName = "Ruta.Reporte, Ruta" };
            MyReportViewer.ReportSource = report;

        }
</script>
    <form id="main" method="post" action="">
        <telerik:ReportViewer ID="MyReportViewer" runat="server" Height="1100px" Width="100%" DocumentMapVisible="False" ParametersAreaVisible="False" ShowDocumentMapButton="False" ShowHistoryButtons="False" ShowNavigationGroup="True" ShowParametersButton="False" ShowPrintPreviewButton="False" ShowRefreshButton="False" Skin="WebBlue" Visible="True" ></telerik:ReportViewer>
</form>

 

0
Todor
Telerik team
answered on 03 Apr 2020, 02:26 PM

Hello Rosbel,

My understanding is that you would like to assign a DataSet as DataSource for a report in the code. For this purpose, you have to instantiate the report, modify its DataSource and then pass it to the Reporting engine wrapped in an InstanceReportSource.

From the settings of the ReportViewer, I assume that you use the Html5 Web Forms Report Viewer. It requires a Telerik Reporting REST Service, where the reports are rendered. To achieve the requirement you will need to create a Custom Report Resolver. Both the report and the data should be accessible by the resolver. You may check How to display a report via InstanceReportSource in the HTML5 Viewer KB article for details.

Regards,
Todor
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Abhay
Top achievements
Rank 1
Answers by
Peter
Telerik team
Abhay
Top achievements
Rank 1
Hrisi
Telerik team
Rosbel
Top achievements
Rank 1
Todor
Telerik team
Share this question
or