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

Timing issue causing message One or more parameters are not set or have invalid values

2 Answers 129 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 11 Mar 2011, 08:40 PM
Hello. We are using a Silverlight ReportViewer to call into a class library that contains a report definition. 90% of the time our report comes up fine. But the other 10% of the time, we get the message:
"One or more parameters are not set or have invalid values"
in the report that pops up.

I am calling the report the same way every time, so that leads me to believe there is some kind of timing issue. [EDIT: When this happens, I see the report briefly flash on the screen. Then I get the message about the invalid values. At that point, if I click the refresh button the report viewer, the report comes up fine. It comes up very fast. So, it's not like it's rendering the report when I click the refresh button.]

I was hoping Telerik could see something that we are doing wrong that may be causing this timing issue. Again, we are calling the report with the same parameters, so it's not like we're leaving out a parameter.

In our XAML, we have a ReportViewer control. In the RenderBegin event of the ReportViewer, we are doing this (leaving out a lot of parameters for clarity - also taking out names that identity our business model):

object[] param1 = new object[MyCollection.Count];
object[] param2 = new object[MyCollection.Count];
int loopCounter = 0;
foreach (Widget myWidget in MyCollection)
{
   param1[loopCounter] = myWidget.param1;
   param2[loopCounter] = myWidget.param2;
   loopCounter++;
}
args.ParameterValues["Param1"] = param1;
args.ParameterValues["Param2"] = param2;

In the NeedDataSource event of the report, we are doing this. (ReportItem is a class I defined.)

Telerik.Reporting.Processing.Report myReport = (Telerik.Reporting.Processing.Report)sender;
System.Collections.Generic.List<ReportItem> reportItems = new System.Collections.Generic.List<ReportItem>();
object[] param1Array = (object[])myReport.Parameters["Param1"].Value;
object[] param2Array = (object[])myReport.Parameters["Param2"].Value;
for (int loopCounter = 0; loopCounter < param1Array.Length; loopCounter++)
{
   ReportItem ri = new ReportItem();
   ri.param1 = param1Array[loopCounter].ToString();
   ri.param2 = param2Array[loopCounter].ToString();
}
this.DataSource = reportItems;

Not sure if this matters or not, but we are displaying the ReportViewer in a ChildWindow. In the code-behind of the XAML of the child  window, we are doing this:

public ShowMyReport()
{
    InitializeComponent();
}
private void ChildWindow_Loaded(object sender, RoutedEventArgs e)
{
    MyViewModel vm = (MyViewModel)this.DataContext;
    vm.RefreshReport += new System.Action(vm_RefreshReport);
    ReportViewer1.RenderBegin += vm.OnBlahRenderBeginCommand; // This points to the RenderBegin event I talked about above
    vm.UpdateReport();
}
void vm_RefreshReport()
{
    ((ReportViewerModel)this.ReportViewer1.DataContext).RefreshReportCommand.Execute(null);
}

Thanks.


2 Answers, 1 is accepted

Sort by
0
Milen | Product Manager @DX
Telerik team
answered on 17 Mar 2011, 03:49 PM
Hello Justin,

Sorry for the late reply - we were busy preparing the new Q1 2011 release.

The issues you experience are most probably related with the last of your code snippets. Why do you need to call the RefreshReport command manually? It is not meant to be used this way. The report is refreshed automatically when you change the Report property of the viewer (through code behind or in XAML).

It is possible that you fire the RefreshReport command before the ReportViewer is made visible / initialized on your page. Unfortunately we cannot examine what exactly is happening without a running sample illustrating the observed behavior. Please review your approach and send us a runnable sample if the problem persists.

Best wishes,
Milen
the Telerik team
0
john doe
Top achievements
Rank 1
answered on 19 Mar 2011, 10:28 AM

Thanks for reply.

I also have same problem but your suggestion seems to have fixed it.

I first struggled how to fire RenderBegin event:

  "private void ReportViewerReportPrintCrosstab_RenderBegin(object sender, Telerik.ReportViewer.Silverlight.RenderBeginEventArgs args)
  {..."

It is NOT  necessary to call 

"((ReportViewerModel)this.ReportViewerReportPrintCrosstab.DataContext).RefreshReportCommand.Execute(null);" to fire RenderBegin

It is enough to just set .Report = 'xxxx....' and THIS alone fires _RenderBegin event and report is displayed ok.

Thx again.

Damir

ps: great components btw ;)

Tags
General Discussions
Asked by
Justin
Top achievements
Rank 1
Answers by
Milen | Product Manager @DX
Telerik team
john doe
Top achievements
Rank 1
Share this question
or