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

Passing Parameters to filter report

10 Answers 241 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bryan Hughes
Top achievements
Rank 1
Bryan Hughes asked on 27 Aug 2012, 09:55 PM
Hello,

I have a reports that I built in seprate class in web app.  The reports are then viewed in web report viewer that also contains date inputs and drop downs to pass parameters to filter report in a custom user control (ascx).  The report initally loads fine, but I cannot change the parameters with the drop down controls. What am I missing?

Sub LoadReport(ByVal serviceTypeID As Integer)
        Dim report As Telerik.Reporting.Report = DirectCast(Me.rvServicesSummary.Report, Telerik.Reporting.Report)
        Dim thisUser As String = Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey.ToString
        Dim agencyGuid As String = UserProfile.GetCurrentAgencyGUID.ToString
 
 
        report.ReportParameters("ServiceTypeID").Value = serviceTypeID
        report.ReportParameters("CurrentUserID").Value = thisUser
        report.ReportParameters("AgencyGUID").Value = agencyGuid
 
 
End Sub
 
Protected Sub RcbServicesSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rcbServices.SelectedIndexChanged
 
        LoadReport(CType(sender, Telerik.Web.UI.RadComboBox).SelectedValue)
End Sub

10 Answers, 1 is accepted

Sort by
0
Bryan Hughes
Top achievements
Rank 1
answered on 28 Aug 2012, 10:08 PM
I have tried almost ever scenerio suggest on forums.  I have added a preview button on my custom UI to refresh report viewer with new parameters, but still no luck.  The report is part of a reports class, and the data is retrieved through a strored procedure.  I can't setup out of box filter, because of security and bl passed in from membership in the web app.  How do you change/refresh report with new parameters passing parameters outside of report class?  Here is my current code.
Protected Sub RbtnPreviewClick(ByVal sender As Object, ByVal e As EventArgs) Handles rbtnPreview.Click
 
        'Dim report As Telerik.Reporting.Report = DirectCast(Me.rvServicesSummary.Report, Telerik.Reporting.Report)
        Dim report As New WISHReportsClassLibrary.ReportServicesSummaryMaster
        Dim thisUser As String = Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey.ToString
        Dim agencyGuid As String = UserProfile.GetCurrentAgencyGUID.ToString
        report.ReportParameters("ServiceTypeID").Value = rcbServices.SelectedValue
        report.ReportParameters("CurrentUserID").Value = thisUser
        report.ReportParameters("AgencyGUID").Value = agencyGuid
        rvServicesSummary.Report = report
        Me.rvServicesSummary.RefreshReport()
 
    End Sub

0
IvanY
Telerik team
answered on 30 Aug 2012, 04:10 PM
Hello Bryan,

We have tested setting the parameters both through the report source and through the report itself. In the button click event handler the report in the report viewer is changed and everything works as expected. As a side note we can recommend you to use the ReportSource property of the Report Viewer instead of the Report property, which is now obsolete. For more information about Report Sources please check the respective article.

As for your code - it seems to be OK, but we cannot tell for sure since we do not have the full source. What you can do is create a very simple example using the examples that get installed along with the product (located in Start -> Telerik -> Reporting Q2 2012 -> Visual Studio 2010 Examples -> C# Solution). For example the Invoice report has a single parameter - try setting this parameter through the external controls you use and check if everything works. Then add the custom logic that you have so that you get closer to the real example.

Additionally you can send us a runnable sample that exhibits the issue so that we are able to view and debug it at our end - this will help us identify the culprit faster. If your data is sensitive you can always use hardcoded dummy data (the ObjectDataSource may help you) instead of the real one.

Kind 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 >

0
Bryan Hughes
Top achievements
Rank 1
answered on 31 Aug 2012, 08:51 PM
Tried upgrading to Q2 2012 from Q3 2011 but gave to many obsolete errors after upgrade and don't have time to figure them out right now.

I looked at Q2 2012 VB Example, but one thing I would have a problem with is "All" in the dropdown filter list so it shows all orders instead of just selected order.

I have a question.  When report is first rendered it creates a session for the data and the filters work of the cached session data, not re-queying the datastore?  If this is true would the best solution, be to reload datasorce for report in preview button and refresh report with new parameters?

The app I have is pretty complicated and there are at least 6 reports with 2 to 4 sub reports in each thme in the report class.  It would take sometime to figure out a way to send you a scaled down version of the app.
0
IvanY
Telerik team
answered on 03 Sep 2012, 05:21 PM
Hello Bryan,

You can get rid of the obsoletes in a very simple way (this is valid only if they are in the designer.cs file) - just open each report in the designer and change anything, the best would be to turn on/off the snap grid. This will enforce the report to be pre-serialized, using the new syntax.

As for your question - when you change the parameter the query is executed again as changes may have been introduced to the database.

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
Bryan Hughes
Top achievements
Rank 1
answered on 03 Sep 2012, 11:01 PM
Tried this but I cannot even get to properties to change something in designer because it gives unit type and other obsolute errors.
0
IvanY
Telerik team
answered on 04 Sep 2012, 03:43 PM
Hello Bryan,

The messages that prevent you from opening the designer are not the obsolete warnings but some other errors, which are typically caused by the resx file in the report definition. You can run the Upgrade Wizard to make sure your upgrade has been successful.

If the problem persists, in order to advise you more appropriately we will need additional information about these errors or you can just send a sample report that reproduces that issue. We will fix it and provide you with steps on how to fix the rest of the reports.

Greetings,
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
Bryan Hughes
Top achievements
Rank 1
answered on 11 Sep 2012, 09:18 PM
I have tried everything.  All parameters are being passed.  The report is updated with date values, but never updates value from drop down list.
Sub LoadReport(ByVal serviceTypeID As Integer, ByVal startDate As DateTime, ByVal endDate As DateTime)
        Dim report As Telerik.Reporting.Report = CType(Me.rvServicesDetail.Report, Telerik.Reporting.Report)
        Dim agencyGuid As String = UserProfile.GetCurrentAgencyGUID.ToString
 
        report.ReportParameters("CurrentUserID").Value = thisUser.ProviderUserKey.ToString
        report.ReportParameters("AgencyGUID").Value = agencyGuid
        report.ReportParameters("ServiceTypeID").Value = serviceTypeID
        report.ReportParameters("StartDate").Value = startDate
        report.ReportParameters("EndDate").Value = endDate
 
        Me.rvServicesDetail.RefreshReport()
 
 
    End Sub
    Protected Sub BtnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)
 
        Dim servicesTypeId As Integer = CInt(rcbServices.SelectedValue.ToString)
        Dim startDate As DateTime = rdStartDate.SelectedDate
        Dim endDate As DateTime = rdEndDate.SelectedDate
 
        LoadReport(servicesTypeId, startDate, endDate)
 
    End Sub

What is the issue?
0
IvanY
Telerik team
answered on 17 Sep 2012, 08:58 AM
Hello Bryan,

Your code seems to be ok, but we cannot tell for sure as we do not have the whole thing. Because of that it will be best if you can provide us with a runnable sample that exhibits your issue so that we can reproduce it locally. If you have any sensitive data you can always strip it from the sample.

Kind 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 >

0
Bryan Hughes
Top achievements
Rank 1
answered on 17 Sep 2012, 09:04 PM
I have narrowed it down to the value being passed from drop down list to report parameter.  It is an Integer but the report throws an exception if I try to convert
An error has occurred while processing Report 'ReportServicesDetailMaster': An error has occurred while executing function CInt(). Check InnerException for further information. ------------- InnerException ------------- Exception has been thrown by the target of an invocation. ------------- InnerException ------------- Unable to cast object of type 'System.Object[]' to type 'System.IConvertible'.

0
IvanY
Telerik team
answered on 20 Sep 2012, 12:04 PM
Hello Bryan,

If the value is truly an int then the exception would not occur. Check your code more thoroughly and also try creating a sample in which you can test only the conversion of the variable. As stated below you can always send as a runnable sample that exhibits the issue.

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
Bryan Hughes
Top achievements
Rank 1
Answers by
Bryan Hughes
Top achievements
Rank 1
IvanY
Telerik team
Share this question
or