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

Parameters in Reportbook

4 Answers 162 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jan
Top achievements
Rank 1
Jan asked on 23 Nov 2009, 02:48 PM
Hello,
I have a scenario where I need to pass a session varable value to a report in a reportbook on a html page. I haven't been able to find any code for this in the forums or figured it out by my self.
Depending on who's logging in to my reportpages different report results will appear. I store the users id in a sessionvariable on loggin. I've found a solution for a single report but not when I want to put the report in a reportbook.

I'm thankful for any directions and/or codesamples.

Best regards

Janne

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 23 Nov 2009, 05:39 PM
Hi Jan,

You can access any object in the report through its API. Here is a sample code:

Telerik.Reporting.IReportDocument mybook = new ReportBookCL.MyReportBook();
List<Report> reports = new System.Collections.Generic.List<Report>(mybook.Reports);
reports[0].ReportParameters[0].Value = <value_from_session_var>;
ReportViewer1.Report = mybook;

Note that in the snippet above we use a class inheriting ReportBookControl named ReportBookCL.MyReportBook. If you create your book at runtime you should use: Telerik.Reporting.IReportDocument mybook = this.ReportBook;

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jan
Top achievements
Rank 1
answered on 25 Nov 2009, 08:25 AM
Hello Steve!

Thanks for your as always quick reply!
The parameter gets passed ok now but there's only one of two reports that
show up in the reportbook.

Thank you!

Here's my code:
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (Page.Request.Cookies["kundIdNr"].Value.ToString() != "")  
        {  
            Telerik.Reporting.IReportDocument mybook = this.ReportBookControl1;  
            System.Collections.Generic.List<Telerik.Reporting.Report> reports = new System.Collections.Generic.List<Telerik.Reporting.Report>(mybook.Reports);  
            reports[0].ReportParameters[2].Value = Page.Request.Cookies["kundIdNr"].Value.ToString();  
            ReportViewer1.Report = mybook;  
        }  
 
 
        else  
        {  
            Response.Write("NÃ¥gonting gick fel. Din browser kanske inte stödjer cookies.");  
        }  
}  
 
 
 
<form id="form1" runat="server">  
    <div> 
       
        <telerik:ReportViewer ID="ReportViewer1" runat="server" > 
        </telerik:ReportViewer> 
        
        <telerik:ReportBookControl ID="ReportBookControl1" runat="server">  
            <Reports> 
                 <telerik:ReportInfo Report="rapport1.kostperaktvtyp, rapport1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">  
                </telerik:ReportInfo>                 
                <telerik:ReportInfo Report="rapport1.kostperps, rapport1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">  
                </telerik:ReportInfo><%----%>   
            </Reports> 
        </telerik:ReportBookControl> 
      
    </div> 
    </form> 
0
Steve
Telerik team
answered on 25 Nov 2009, 09:47 AM
Hello Jan,

I've prepared a sample project that works fine on my end and attached it here for your convenience. Please review it and let us know if further help is needed.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jan
Top achievements
Rank 1
answered on 01 Dec 2009, 07:53 AM
Hello Steve,

Sorry for the delay in my response but I've been out of the office for a few days.
Thanks for your solution, works like a charm now even if do not really understand
what I did wrong. But thats of less importance right now :-)

Thankfully

Janne P
Tags
General Discussions
Asked by
Jan
Top achievements
Rank 1
Answers by
Steve
Telerik team
Jan
Top achievements
Rank 1
Share this question
or