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

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

1 Answer 51 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jeroen
Top achievements
Rank 1
Iron
Jeroen asked on 11 Oct 2016, 07:20 AM

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

1 Answer, 1 is accepted

Sort by
0
Accepted
Jeroen
Top achievements
Rank 1
Iron
answered on 11 Oct 2016, 08:25 AM

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

 

 

Tags
General Discussions
Asked by
Jeroen
Top achievements
Rank 1
Iron
Answers by
Jeroen
Top achievements
Rank 1
Iron
Share this question
or