i have a report parameter defined (Screenshot#1)
i want to set a Visible property of a subreport to whatever the user input at the visible report parameter.
i use the following code at the Master Report:
private
void
subReport1_ItemDataBound(
object
sender, EventArgs e)
{
(sender
as
Telerik.Reporting.Processing.SubReport).Visible = (
bool
)
this
.ReportParameters[
"ShowField"
].Value;
}
no matter what i do the Value of the parameter is always True, even if i don't give the parameter a value when i define it.
doesn't matter if i check or uncheck the checkbox of the parameter shown of the screen.
please can someone help me?
thanks.
10 Answers, 1 is accepted
We are unable to reproduce the issue you have experienced with the provided code snippet. You have mentioned a checkbox parameter when the default UI for Boolean Report Parameter is a two radio buttons. If you are using a custom UI then you will need a custom Preview button.
To avoid any confusion please check out the attached sample project, we would appreciate if you modify the attached project to reflect the problem or if it is showing what you think is wrong - please elaborate.
Peter
the Telerik team
as shown in the screenshot - the parameter is a boolean type parameter that i set its' Visible property to True,
what i get in the ReportViewer is a Checkbox that represents the parameter, not a radio button.
i'm using the latest version of Reporting and Rad Controls.
i should have mentioned i work in WPF on visual studio 2008, so i really don't know what to do with the silverlight project you uploaded.
plus, when i try the open your project i get an error message (shown in the screenshot i've attached).
so if you be so kind as to upload a new WPF project, it will be great - thanks.
Unfortunately we are able to reproduce the issue related to the WPF Report Viewer that a single value boolean parameters is returning an incorrect value. We have logged it in our bug tracking system and we will introduce a fix with a subsequent internal build or service pack. In the meantime as a workaround our suggestion would be to use a Custom UI for the Parameters as shown in the attached WPF project.
Your Telerik points have been updated as a token of gratitude for bringing the first problem to our attention. Please excuse us for the temporary inconvenience.
Peter
the Telerik team
i'm sorry but i can't seem to open the project you uploaded, as i mentioned i'm using visual studio 2008, could it be that this project
is ment for VS2010?
can you please upload the project again?
thanks so much.
I have attached a Visual Studio 2008 solution of the sample project.
Best wishes,Peter
the Telerik team
I currently have the same problem in the Silverlight Report Viewer 2010 Q2 (VS2010).
From the WPF sample attached It seems that the reporting parameters control is hidden and "manual" report parameters are used, correct?
this implies that all the parameters would have to be coded for each of the reports that uses a boolean value as a parameter.
Could you please post a sample workaround for silverlight if this is not the case.
Regards,
K
This issue has been fixed. You can find the fix in the Latest Internal Build, which you can download from your Telerik Account.
Kind regards,
Peter
the Telerik team
I seem to have the same problem, I am using the latest telerik report Q3 2012
I am just following the sample shown in the video "Reporting - SubReports" as shown here:
http://www.telerik.com/support/trainer/reporting.aspx
I am using Visual Studio 2010, the video is using Visual Basic, I am using C# and
this is the code I have almost at the last part of the video:
private void subReport1_ItemDataBound(object sender, EventArgs e)
{
Telerik.Reporting.Processing.SubReport sr = sender as Telerik.Reporting.Processing.SubReport;
sr.Visible = (bool) (this.ReportParameters["ShowEmployees"].Value);
The code above doesn't work, and it gives me an error:
"An error has occurred while processing SubReport 'subReport1': Specified cast is not valid."
When I change the code to this:
private void subReport1_ItemDataBound(object sender, EventArgs e)
{
Telerik.Reporting.Processing.SubReport sr = sender as Telerik.Reporting.Processing.SubReport;
//sr.Visible = (bool) (this.ReportParameters["ShowEmployees"].Value);
string str = this.ReportParameters["ShowEmployees"].Value.ToString();
bool bVal = str == "= True";// it is always true (str.Length == 5);
sr.Visible = bVal;
}
it seems to work, but when I switch to preview mode and change the radio button from True to False, nothing happens, looks like the value Never changes to False (it is always True).
What am I doing wrong? I just followed the sample coding shown in the video:
http://www.telerik.com/training.videos/24_Reporting_Subreports.zip
thanks for any help.
Your code will return the default set value for the report parameter, as it calls the report definition. In order to get the report parameters values passed by the user you need the report processing object:
private void subReport1_ItemDataBinding(object sender, EventArgs e)
{
Telerik.Reporting.Processing.SubReport sr = sender as Telerik.Reporting.Processing.SubReport;
sr.Visible = (bool)(sr.Report.Parameters["ShowParameter"].Value);
}
The same can be achieved by binding the subReport item Visible property to the report parameter value. Both approaches are illustrated in the attached sample project.
I hope this helps.
All the best,
Stef
the Telerik team
HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!