Question

i used Telerik reporting for my aspx project and in this project i want to user can set some item of report . for achieve this goal i use parameter and create param like pic 1 and in fig 2 are property of this parameter and i use it in my report like fig 3 but at least when i run my project i see fig 4 my question is : is it my code wrong and how can i set an item of my report by user in report space when i use parameters they load and show in a parameter area how can i showing them in detail space of report? whats wrong in my code ?enter image description here here its my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using schduleing_report;//its my dll report

namespace telerikreporttest
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Report2 report = new Report2();

            var instanceReportSource = new Telerik.Reporting.InstanceReportSource();
            instanceReportSource.ReportDocument = new schduleing_report.Report2();
            instanceReportSource.Parameters.Add("param", "hi it work");
            this.ReportViewer1.ReportSource = instanceReportSource;

            instanceReportSource.Parameters.Add("testparam", "textbox2 is work too");

            ReportViewer1.RefreshReport();

        }
    }
}
Was it helpful?

Solution

when you have defined the first parameter i.e. "param", you have selected MultiValue=True. So when you read the value of the parameter directly into a text box - it will say the type which is object array. Multivalue will make the textbox to accept more than one value.

Instead if you set the MultiValue=false, the parameter will always hold only 1 value and then it will display the right value on your report.

If you need to have MultiValue=true on param parameter - then do the following to get the text into the textbox on the report:

  • In the designer - right click on the textbox. select expression
  • In the edit expression window - add the following expression - = Join(", ", Parameters.param.Value)

Run the report, now you will the correct text set as value of the textbox.

The Join() function takes 2 parameters. first one is the delimiter string and second is the object array which contains values which needs to be joined. So when MultiValue is set to true, the parameter value is that of object[]. So you need to convert that to text format by using the join() function.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top