How can i post parameter to the reportViewer from silverlight

25 posts, 1 answers
  1. wang zhong
    wang zhong avatar
    29 posts
    Member since:
    Jan 2010

    Posted 01 Feb 2010 Link to this post

    Hi all
    I want post a parameter to the reportViewer,
    who can help me?
    thank you~~
  2. wang zhong
    wang zhong avatar
    29 posts
    Member since:
    Jan 2010

    Posted 02 Feb 2010 Link to this post

    At the silverlight side
    the Class report does not support
    " this.ReportViewer1.Report.ReportParameters["MyParam"].Value = "";"
    It does not have the property ReportParameters,
    So i can't post the parameter to the report.
  3. DevCraft banner
  4. Answer
    Steve
    Admin
    Steve avatar
    10941 posts

    Posted 02 Feb 2010 Link to this post

    Hello wang zhong,

    Are you using the web report viewer or the native Silverlight viewer we introduced in Q3 2009? If the first, then use a code like this:

    Telerik.Reporting.Report report = (Telerik.Reporting.Report)this.ReportViewer1.Report;
    report.ReportParameters["MyParam"].Value = <your_value>;

    If you are using the Silverlight viewer, please review the following KB article: Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.

    Sincerely yours,
    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.
  5. wang zhong
    wang zhong avatar
    29 posts
    Member since:
    Jan 2010

    Posted 02 Feb 2010 Link to this post

    thanks very much,i will try it.
    If any question i will ask you again~~
    thanks again
  6. John Cobb
    John Cobb avatar
    5 posts
    Member since:
    Feb 2010

    Posted 16 Feb 2010 Link to this post

    I attempted to follow the document you referred to: " Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.".  The paramters I assigned were not passed from the viewer to the report.  The report does not even complain about having null parameters.  I double checked the parameter names to make sure there were no misspellings.  The only difference that I see is that I am exposing the viewer in a silverlight child window.  Is this a issue?

    -John Cobb
  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 17 Feb 2010 Link to this post

    Hi John,

    If the RenderBegin event handler is being called then there is no reason why the parameters would not be passed. Try debugging your application to see what you have for args.ParameterValues["YourParam"].
    If you are having trouble identifying what is the problem, please open a support ticket and attach a sample runnable project that we can review.

    All the best,
    Steve
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  8. John Cobb
    John Cobb avatar
    5 posts
    Member since:
    Feb 2010

    Posted 17 Feb 2010 Link to this post

    Thanks.  I did some testing and I did determine that the parameters are being passed as you said.  However, is there a way to access the args object from inside the report constructor?  My datasource is a SQLServer function that requires a start date and an end date.

        public partial class ReportState : Telerik.Reporting.Report  
        {  
            public ReportState()  
            {  
                /// <summary>  
                /// Required for telerik Reporting designer support  
                /// </summary>  
                InitializeComponent();  
     
                var rr = new ReportRepository();  
                var rl = rr.GetAll(new DateTime(2010, 1, 1), new DateTime(2010, 2, 28));  
                this.table1.DataSource = rl;  
            }  
        } 


         In the call to rr.GetAll(...), I would like to replace the 2 parameters with the parameters I set in the args object in the RenderBegin event.  Is this possible?  When I access this.ReportParameters, I get the report parameter definitions.  Is there a way to programmatically change the ReportParameter.Value in the RenderBeginEvent?

  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 22 Feb 2010 Link to this post

    Hello John,

    You can't access parameters in the report constructor because they are not set until after the instance is created. This is not something specific to Telerik Reporting, but applicable for any .NET class.

    Kind regards,
    Steve
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  10. John Cobb
    John Cobb avatar
    5 posts
    Member since:
    Feb 2010

    Posted 22 Feb 2010 Link to this post

    If you are passing the args object through the WCF service and then invoking the report constructor, why isn't this object accessible by the constructor?  During my debugging, the RenderBegin event is called before the constructor for the report is called.  This suggests that the args obj exists on the server at this point but is simply not exposed.
  11. Charlie
    Charlie avatar
    24 posts
    Member since:
    Jan 2009

    Posted 25 Feb 2010 Link to this post

    Hey John,

    I am having the same problem that you are having.   I was expecting to be able to get the values in the constructor as well.  I am using Business Objects for my report data source.
  12. John Cobb
    John Cobb avatar
    5 posts
    Member since:
    Feb 2010

    Posted 26 Feb 2010 Link to this post

    Turns out that if you use the NeedDataSource event, the parameters are available there via this.ReportParameters.  Set the DataSource = null in the constructor and set the reports NeedDataSource to some function.  My problem at that point is that I am using NHibernate which requires the current HttpContext from my original web call.  Since the NeedDataSource event handler is being processed in a different thread, the HttpContext is not available. 

        public partial class ReportU : Telerik.Reporting.Report  
        {  
     
            public ReportU()  
            {  
                /// <summary>  
                /// Required for telerik Reporting designer support  
                /// </summary>  
                InitializeComponent();  
     
                this.DataSource = null;  
            }  
     
            private void ReportU_NeedDataSource(object sender, System.EventArgs e)  
            {  
     
                var sqlhelper = new SQLHelper();  
     
                var sqlParms = new Dictionary<stringobject>();  
                sqlParms["startDate"] = (DateTime)this.ReportParameters["StartDate"].Value;  
                sqlParms["endDate"] = (DateTime)this.ReportParameters["EndDate"].Value;  
     
                var rl = sqlhelper.GetReportRowList(sqlParms);  
     
                this.DataSource = rl;  
            }  
        }  

    The SQLHelper class is just a wrapper around standard .Net SqlClient class methods.  Set the NeedDataSource event handler in the designer properties for the report.

    John
  13. Charlie
    Charlie avatar
    24 posts
    Member since:
    Jan 2009

    Posted 26 Feb 2010 Link to this post

    Thanks John.  This is exactly what I was looking for.  I wish there ReportParameter supported custom .NET Objects as well since it is use in a WCF Service.

    Thanks,

    Charlie J.
  14. rafal piotrowski
    rafal piotrowski avatar
    2 posts
    Member since:
    Oct 2009

    Posted 07 Mar 2010 Link to this post

    Hi,
    I have problem with this solution, as after setting again the DataSource of the report, the report does not respond to the change (i.e. it does not use the data supplied)!!!!
    Any idea how to solve this?
    /rp
  15. rafal piotrowski
    rafal piotrowski avatar
    2 posts
    Member since:
    Oct 2009

    Posted 07 Mar 2010 Link to this post

    I found the problem

    int the NeedDataSource event handler method I was setting the report datasource by 

    this.DataSource = aDataSet;

    instead one need to do the following

    (sender as Telerik.Reporting.Processing.Report).DataSource = aDataSet;

    Does anyone knows WHY?

    regards
    rp
  16. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 08 Mar 2010 Link to this post

    Hello rafal piotrowski,

    The following help topics would answer your question:

    Kind regards,
    Steve
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  17. Amruta
    Amruta avatar
    18 posts
    Member since:
    Apr 2009

    Posted 28 Apr 2010 Link to this post

    Hi,
    Following is the scenario -
    I have a silverlight application where i do some search for the given keyword and i get a list of items. I want to create a report for this list of items. I want to open the report on click of a link on xaml page. Also, i want to open the same report in separate browser for different search criteria (multiple reports using separate browser window).
    I tried to host a reportviewer(Telerik.ReportViewer.WebForms) in a separate aspx page and i navigate to this aspx page in click event of the link. (i am able to open the report in separate windows on a click)
    How can i pass the list of items (the search result) from xaml page to this report? Or is there any other way to accomplish this functionality? 

    Can we pass a list of string variables from xaml to aspx or directly to the telerik report?
    Regards. 
  18. Greg Sipes
    Greg Sipes avatar
    24 posts
    Member since:
    Apr 2010

    Posted 17 Feb 2011 Link to this post

    Steve or John,
         Have there been any updates to this issue? I'm working in VB, but I followed John's idea by using the NeedDataSource event, but it is telling me that the object reference is not set to an instance of an object . I've checked my typing.....is it different threads? I'm pretty sure I've read just about every article and forum here on Telerik about the issue and I'm still stuck..... I put breakpoints on the RenderBegin event of the reportViewer, one on the constructor of the report with two parameters, and one on the NeedsDataSource event.
     The renderBegin event hits and I set the two parameters for the report's constructor
    args.ParameterValues("sale") = SaleNo
            args.ParameterValues("custID") = CustomerID

    Next, the NeedDataSource event is hit inside the report
    SaleNo = DirectCast(Me.ReportParameters("sale").Value, Integer)
            CustomerID = DirectCast(Me.ReportParameters("custID").Value, String)


    .....Why wouldn't the reports constructor with the two parameters be hit? But more importantly, when the NeedsDataSource event fires off, why aren't the two parameters that I supplied in the Me.ReportParameters collection?

    Any help would be greatly appreciated!

  19. raj
    raj avatar
    15 posts
    Member since:
    May 2011

    Posted 16 May 2011 Link to this post

    Does someone have a working solution to pass parameter from client to report in server using silverlight? Though following all the  above mentioned steps i don seem to be getting .. Always this.reportparameters.count==0... Is telerik really having a functionality of sending parameters from client to web? Someone just help me out.. Im fed up.... :(
  20. Greg Sipes
    Greg Sipes avatar
    24 posts
    Member since:
    Apr 2010

    Posted 16 May 2011 Link to this post

    I feel you Raj! I gave up on Telerik Reporting and went to SQL Reporting, which comes with SQL. Parameter passing is simple in SQL Reporting....
  21. raj
    raj avatar
    15 posts
    Member since:
    May 2011

    Posted 17 May 2011 Link to this post

    Hi Greg Sipes

                          I searched for this solution a lot over the net. There is no one to help here...

  22. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 19 May 2011 Link to this post

    Hi guys,

    As far as we're aware SSRS do not offer a Silverlight report viewer. To provide the ability to specify the parameter values from the Silverlight client we have added an event to the Silverlight reportviewer control called RenderBegin. More information is available in the Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer help article.

    Regards,
    Steve
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  23. raj
    raj avatar
    15 posts
    Member since:
    May 2011

    Posted 19 May 2011 Link to this post

    Hi Steve...
                    Im really sorry to say that im tired of the link you post everywhere programmattic initialisation bla bla bla.. That doesn't work..No values gets passed from client to web through your render begin. And as far as i have browsed through i never even found any example to do that.So could you please provide us any silverlight example which does reporting by passing parameters from client side..

    Regards
    Raj
  24. Karlkim Suwanmongkol
    Karlkim Suwanmongkol avatar
    41 posts
    Member since:
    Aug 2012

    Posted 19 May 2011 Link to this post

    Hi Raj,
       The parameter passing in Silverlight does work. We have several projects utlizing that. One thing that I can suggest without seeing any of your code is to make sure that the "ReportParameters" property match all parameters that you want to pass. I always forget about that when I create a new report.
    Good luck!
    --karlkim
  25. Stuart
    Stuart avatar
    3 posts
    Member since:
    Aug 2010

    Posted 30 Aug 2011 Link to this post

    For the benefit of any others that come across this post - the report parameters are not directly available in the constructor of the report (I think it is mentioned somewhere here).

    So, you need to use code like this:

    public partial class Report : Telerik.Reporting.Report
    {
        public Report()
        {
            InitializeComponent();
            this.NeedDataSource += (o, e) =>
            {
                foreach (var reportParameter in this.ReportParameters)
                {
                    // Read out the value of the report parameter here.
                }
            };
        }
    }

    Hope that helps - it took me awhile to discover this.

    Stuart


  26. Brett
    Brett avatar
    7 posts
    Member since:
    Dec 2011

    Posted 12 Mar 2012 Link to this post

    I fought with this issue for a while as well.

    I was futzing around with the reporting to see if I could make it do everything I needed (parameter passing included.)  as such I started with the overall program structure rather than making a fully-functional report.  I suspect that if I had learned how to create a complete report before I tried to reference it from silverlight, this would not have been an issue.

    Anywho, this was the big "aha."  I hadn't seen this posted anywhere while trying to resolve my issue:  [report].ReportParameters needed to be specified at design time in addition to [sqlDataSource].Parameters.  in retrospect it seems silly I missed this, but that was my issue.

    Silverlight passes its parameters into [report].ReportParameters.  I needed to configure the sqlDataSource to reference these values.

    so in my case (All at design time):

    - I created a sqlDataSouce that had @StartTime as a parameter in the query
    - I Added "StartTime" as a ReportParameter to the Report
    - back in the sqlDataSource "Parameters..." dialog I set @StartTime =Parameters('StartTime').Value

    this worked, I danced a merry jig.
Back to Top
DevCraft banner