Programmatically set list for report parameters - errro object reference not set

2 posts, 1 answers
  1. Jeroen
    Jeroen avatar
    8 posts
    Member since:
    Jun 2015

    Posted 11 Oct Link to this post

    Hello,

     

    for a report a like to have a dropdown box with values to choose from.

     

    According to examples I put the following code in the constructor:

    ReportParameters["Agent"].AvailableValues.DataSource = new object[];

    ReportParameters["Agent"].AvailableValues.ValueMember = "Fields.Item";

    ReportParameters["Agent"].Visible = true;

    ReportParameters["Agent"].Type = ReportParameterType.String;

     

    When I compile it shows the report with a textbox on top.

     

    Now when I change the code to:
    ReportParameters["Agent"].AvailableValues.DataSource = new object[] {"test"};
    ReportParameters["Agent"].AvailableValues.ValueMember = "Fields.Item";
    ReportParameters["Agent"].Visible = true;
    ReportParameters["Agent"].Type = ReportParameterType.String;

     

    and I try to open the report it says:

    Object reference not set to an instance of an object.

     

    Source: Telerik.ReportViewer.Wpf.

    I use Telerik Reporting Q2 2015.

    I've loooke dover everuthing but I guess still mssing something.

     

    Andy direction would be appreciated.

     

    Kind regards

     

    Jeroen

  2. Answer
    Jeroen
    Jeroen avatar
    8 posts
    Member since:
    Jun 2015

    Posted 11 Oct in reply to Jeroen Link to this post

    Figured it out:

    ReportParameters["Agent"].AvailableValues.ValueMember = "Fields.Item";

    should be

    ReportParameters["Agent"].AvailableValues.ValueMember = "=Fields.Item";

     

    Phh, a simple = missing causing this .

     

    Kind regards

     

    Jeroen

     

     

  3. DevCraft banner
Back to Top