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

How to display telerik report book in mvc3?

3 Answers 156 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mindaugas
Top achievements
Rank 1
Mindaugas asked on 14 Jun 2012, 11:46 AM
Hello, im using Telerik Reporting Q2 2011 version and i can't find any information how to display telerik reporting books in mvc3 application. Would like to load reports dynamically in controller action or something. Thanks indeed for any help or code samples or links. Regards

3 Answers, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 15 Jun 2012, 02:10 PM
Hello Mindaugas,

Displaying Report Book in MVC with our ASP.NET Report Viewer or any other Terlerik Report Viewer is no different from displaying a report. However there is a change in what our viewers can receive as a report source, so currently what you have to do (in code behind) is this:

InstanceReportSource reportSource = new InstanceReportSource();
reportSource.ReportDocument = new MyReportBook();
ReportViewer1.ReportSource = reportSource;

Changing data in the Report Book can be done like this:
reportSource.ReportDocument.Reports.Where(rep => rep.Name == "ReportName").FirstOrDefault().DataSource = myDataSource;

I hope that helps.

All the best,
IvanY
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Mindaugas
Top achievements
Rank 1
answered on 18 Jun 2012, 09:37 AM
hey thank you for replay. which part supposed to be in view ? like i understand your code is controller part? thanks indeed for all help.
0
IvanY
Telerik team
answered on 18 Jun 2012, 01:41 PM
Hi Mindaugas,

The code sample can be in both places - in the controller and in the view (the ASPX page), depends on where you assign the Report Book in the first place. Please have in mind that currently you cannot set the report (in your case the Report Book) with markup.

Here is a sample on how to use the code below in the ASPX page:
<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);

                 InstanceReportSource reportSource = new InstanceReportSource();
                 reportSource.ReportDocument = new MyReportBook();
                 ReportViewer1.ReportSource = reportSource;
        }
    </script>
    <form id="main" method="post" action="">
        <telerik:ReportViewer ID="ReportViewer1" Width="100%" Height="800px" runat="server">
        </telerik:ReportViewer>
    </form>
</body>


Regards,
IvanY
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

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