Monday, February 13, 2012

ASP.NET ReportViewer / Non-String parameters

I am displaying a local report in a ReportViewer control on an asp.net web page. My report contains non-string parameters. How can i set a non-string parameter value on a local report?You will need to call .ToString() on your value to set it on ReportParameter.|||That would result in a string being passed to the report. I want to pass a float or a datetime to the report.

The only way i've been able to get this to work is to create a typed dataset with the "parameters" i want sent and then use aggregation functions (first,sum, etc...) to get to the data into the report. That is a big workaround in order to get a few simple floats and times into my report. Has anyone been able to get this done using another method?
|||If the data type of the parameter is set to integer/float, you can do these operations. And you can always convert between types in a report expression.

1 comment:

Jim E said...

Try just defining the parameter in your report as the data type you want. Then pass it in using .ToString() on the equivalently typed object in your code. The report will do the conversion from the passed string back to the appropriate data type to use in the report.

Post a Comment