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

Report Parameter DisplayMember/ValueMember

2 Answers 288 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aaron Abdis
Top achievements
Rank 1
Aaron Abdis asked on 16 Feb 2010, 05:18 AM
Hello all, I'm writing my very first Telerik report. I am trying to hook up one of the parameters to a "Business Object" datasource.
My datasource is defined as:

Namespace DataObjects 
    Public Class DropDowns 
        Public Shared ReadOnly Property Intervals() As List(Of ListItem) 
            Get 
                Dim lic = New ListItemCollection() 
 
                lic.Add(New ListItem("Raw""0")) 
                lic.Add(New ListItem("15 Minutes""0.25")) 
                lic.Add(New ListItem("30 Minutes""0.5")) 
                lic.Add(New ListItem("1 Hour""1")) 
                lic.Add(New ListItem("6 Hours""6")) 
                lic.Add(New ListItem("12 Hours""12")) 
                lic.Add(New ListItem("1 Day""24")) 
 
                Return (From li As ListItem In lic Select li).ToList 
            End Get 
        End Property 
    End Class 
End Namespace 

My report parameter is defined as (from the report codebehind):

        reportParameter1.Name = "DeviceId" 
        reportParameter1.Type = Telerik.Reporting.ReportParameterType.[Integer
        reportParameter1.UI.AllowBlank = False 
        reportParameter1.UI.AvailableValues.DataMember = "Intervals" 
        reportParameter1.UI.AvailableValues.DataSource = GetType(DataObjects.DropDowns) 
        reportParameter1.UI.AvailableValues.DisplayMember = "Fields.Text" 
        reportParameter1.UI.AvailableValues.ValueMember = "Fields.Value" 
        reportParameter1.UI.Visible = True 
        Me.ReportParameters.Add(reportParameter1) 

When i run the report in the browser, in the area where the report would normally render, it tells me: "The expression contains object 'Fields.Value' that is not defined in the current context." I have tried using Value, Fields.Value, Item.Value, ... and just can't figure out what to put for the DisplayMember and ValueMember to get them to pull the Text and Value properties of the ListItem objects respectively. I even tried leaving them blank, but then it tells me: "Parameter 'DeviceId' has defined AvailableValues, but no ValueMember is specified. Use 'Item' if binding to Array."

Can someone tell me what to put for the DisplayMember and ValueMember properties???
Thanks in advance! 

2 Answers, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 16 Feb 2010, 03:49 PM
Text and Value are incredibly poor choice for naming properties in your own custom class and this way you may cause collision with already defined properties in various namespaces.
I've bound my report parameters through the Report Parameters UI (http://www.telerik.com/help/reporting/designing-reports-parameters.html) and looking at the code it has reportParameter1.UI.AvailableValues.ValueMember = "MyCategory" set as ValueMember, so you can ditch the =Fields. syntax.
It would seem to me that the painless way to proceed would be to create a default constructor for your business object so that you can use the designer UI for binding the parameters.

My 2 cents ..
0
Aaron Abdis
Top achievements
Rank 1
answered on 16 Feb 2010, 03:56 PM
Well, Text and Value are not my choice... if you look at the BO, it is returning a List(Of ListItem).
ListItem is simply the built-in ListItem class from the framework, and Text and Value are the properties which it exposes.
Tags
General Discussions
Asked by
Aaron Abdis
Top achievements
Rank 1
Answers by
Massimiliano Bassili
Top achievements
Rank 1
Aaron Abdis
Top achievements
Rank 1
Share this question
or