An error has occurred while processing TextBox 'textBox1': The expression contains object 'Start' that is not defined in the current context.Hello,
I started off with the ReportCatalog used in the CSharp.ReportExamples.VS2010 solution from which reports hosted in an asp.net class library are loaded. I went ahead and created a custom parameter UI above my Silverlight reportviewer, but i cannot seem to get the target report (using the Navigate to Report action) to receive the passed parameters from the custom ui. I can navigate to the reports but only the default parameter values set for the reports are used. I have tried using the RenderBegin method but it seems the passed parameters are being ignored. I have read a number of blogs on this, but somehow, things are not working.
How can I wire up the parameters from my Silverlight application to the reports?
Below are snippets of my code:
<my1:ReportViewer Name="rptViewer" ….. Report="XXX.ReportsLibrary.ReportCatalog, XXX.ReportsLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ReportServiceUri="../Services/ReportService.svc" RenderBegin="rptViewer_RenderBegin" Loaded="rptViewer_Loaded" />
In the code behind of the page hosting the reportviewer, I have:
void rptViewer_RenderBegin(object sender, RenderBeginEventArgs args) args.ParameterValues.Clear(); args.ParameterValues["dateStart"] = rdpStart.SelectedDate; args.ParameterValues["dateEnd"] = rdpEnd.SelectedDate; ((ReportViewerModel)(rptViewer.DataContext)).ApplyReportParametersCommand.Execute(null);}
One thing I noticed is that the sender is ALWAYS the ReportCatalog. I was expecting that after navigating to ReportX the Sender would be ReportX. So is it that I am trying to apply parameters to the wrong report?
Please help!!!
My last option would be to abandon the idea of custom parameters UI.
Thanks
I am working on an ASPX page where the user enters some information. When the user click the save button I want to save the entered data then call Telerik’s report passing to it the record_id of the new saved data. I cannot find any information on how to pass parameter to a report. Could someone help me on this issue?
Thanks
Maher
' Generate the reportsMe.Cursor = Cursors.WaitCursor' Initialize print settingsDim printerSettings As New System.Drawing.Printing.PrinterSettingsDim printerController As New System.Drawing.Printing.StandardPrintControllerDim reportSource As New InstanceReportSourceDim reportProcessor As New ReportProcessorreportProcessor.PrintController = printerController' Create the report book to add reportsDim reportBook As New ReportBookreportBook.DocumentName = "Credit Vouchers"' Print the report headerprinterSettings.Duplex = Printing.Duplex.SimplexDim rptHeader As New CreditVoucherReportLibrary.ReportTitlereportBook.Reports.Add(rptHeader)Dim c As Integer = 0Dim firstCV As String = ""Dim lastCV As String = ""Dim cn As New SqlConnection(My.Settings.OMSConnectionString)Using cn cn.Open() ' Get the list of voucher numbers to print Dim cmd As SqlCommand = New SqlCommand("Accounts_Payable.get_Credit_Vouchers_Lot_list", cn) cmd.CommandType = CommandType.StoredProcedure IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text) cmd.Parameters.AddWithValue("@Year", YearComboBox.SelectedItem) cmd.Parameters.AddWithValue("@Month", PeriodComboBox.SelectedItem) cmd.Parameters.AddWithValue("@Payment_Number_Code", IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text)) Try Dim r As SqlDataReader = cmd.ExecuteReader If r.HasRows Then While r.Read Dim rptVoucherStatement As New CreditVoucherReportLibrary.CV_Statement Dim rptVoucher As New CreditVoucherReportLibrary.CreditVoucher ' Print Credit Voucher Statement rptVoucherStatement.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem rptVoucherStatement.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem rptVoucherStatement.ReportParameters("PaymentNumber").Value = Trim(r(0)) printerSettings.Duplex = Printing.Duplex.Horizontal ' Add the voucher statement to the report book Try reportBook.Reports.Add(rptVoucherStatement) Catch ex As Exception End Try ' Print Credit Voucher c += 1 rptVoucher.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem rptVoucher.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem rptVoucher.ReportParameters("PaymentNumber").Value = Trim(r(0)) rptVoucher.ReportParameters("LastUpdatedBy").Value = "System" rptVoucher.ReportParameters("IsReprint").Value = False If c = 1 Then firstCV = Trim(r(0)) Else lastCV = Trim(r(0)) End If printerSettings.Duplex = Printing.Duplex.Simplex ' Add the voucher to the report book Try reportBook.Reports.Add(rptVoucher) Catch ex As Exception End Try End While End If Catch ex As Exception End TryEnd Using' Print the summary pageDim rptSummary As New CreditVoucherReportLibrary.CV_Summary_ReportTry Dim range As String = "" If c = 1 Then range = firstCV Else range = firstCV & " - " & lastCV End If rptSummary.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem rptSummary.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem rptSummary.ReportParameters("PaymentNumber").Value = IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text) rptSummary.ReportParameters("RangeOfVouchers").Value = range rptSummary.ReportParameters("NumberOfVouchers").Value = c printerSettings.Duplex = Printing.Duplex.Horizontal ' Add the summary to the report book reportBook.Reports.Add(rptSummary)Catch ex As ExceptionEnd Try' Print the report bookIf PrintPreviewCheckBox.Checked Then Dim dlg As New CreditVoucherPrintPreviewForm dlg.reportBook = reportBook dlg.ShowDialog()Else reportSource.ReportDocument = reportBook reportProcessor.PrintReport(reportSource, printerSettings)End If