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

Parameter ComboBox Selected Value

3 Answers 354 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jaymie
Top achievements
Rank 1
Jaymie asked on 21 Dec 2009, 12:01 PM
Good morning,
I am having an issue with reporting and getting the selected value of a databound combobox. The value only returns the selectedItem.Text of the combobox and I wish to get the selectedValue instead.
Could you let me know what the code would be to achieve this please?

The Lists are defined as:

 
 
    Public Shared Function ReturnTypes() As ForecastTypeCollection 
        Dim pTypeCol As New ForecastTypeCollection 
        For i As Integer = 0 To 2 
            Dim pType As New ForecastType 
            Select Case i 
                Case 0 
                    With pType 
                        .ValueMember = "Both" 
                        .DataMember = "" 
                    End With 
                Case 1 
                    With pType 
                        .ValueMember = "UK" 
                        .DataMember = "UK" 
                    End With 
                Case 2 
                    With pType 
                        .ValueMember = "International" 
                        .DataMember = "EX" 
                    End With 
            End Select 
            pTypeCol.Add(pType) 
        Next 
        Return pTypeCol 
    End Function 
 
    Public Shared Function ReturnPeriods() As PeriodCollection 
        Dim p As New PeriodCollection 
        For i As Integer = 1 To 12 
            Dim pPeriod As New Period 
            With pPeriod 
                .DataMember = i 
                .ValueMember = i 
            End With 
            p.Add(pPeriod) 
        Next 
        Return p 
    End Function 

and then they are assigned to the parameters as below:



    Public Sub New() 
        InitializeComponent() 
 
        Report.ReportParameters()(0).UI.AvailableValues.DataSource = ReturnTypes() 
        Report.ReportParameters()(0).UI.AvailableValues.DataMember = "DataMember" 
        Report.ReportParameters()(0).UI.AvailableValues.ValueMember = "ValueMember" 
 
        Report.ReportParameters()(1).UI.AvailableValues.DataSource = ReturnPeriods() 
        Report.ReportParameters()(1).UI.AvailableValues.DataMember = "DataMember" 
        Report.ReportParameters()(1).UI.AvailableValues.ValueMember = "ValueMember" 
    End Sub 

Then I bind the report as follows:

    Private Sub ForecastNextPeriod_NeedDataSource(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.NeedDataSource 
        Try 
            Dim pCalendar As Calendar = ReturnCurrentYearAndPeriod() 
            Dim pType As String = ReportParameters("Type").Value 
            Dim pPeriodCount As Integer = Me.ReportParameters("PeriodCount").Value 
 
            DirectCast(sender, Telerik.Reporting.Processing.Report).DataSource = ReturnForecastReport(pPeriodCount, pCalendar.Period, pCalendar.Year, pType) 
        Catch ex As Exception 
            MsgBox(ex.ToString) 
        End Try 
    End Sub 

pType and pPeriodCount only grab the selected item. I have tried searching the forums and reading documentation but I can not find anything that explains how to get the selected value.
Any help would be appreciated.

cheers,
Jaymie

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 21 Dec 2009, 01:05 PM
Hi Jaymie,

Unfortunately this is not possible in the current version of the product and we have it logged in our features list. For the time being the only thing you can do is use the same column for ValueMember and DisplayMember.

Please excuse us for the inconvenience.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Amy
Top achievements
Rank 1
answered on 16 Nov 2010, 04:18 PM
Has this been corrected in Q3 2010?  I did not see it addressed in the release history for reporting: http://www.telerik.com/products/reporting/whats-new/release-history/q3-2010-version-4-2-10-1110.aspx

But what is confusing is that you refer to using the DisplayMember and ValueMember as separate fields in your documentation and blog posts: this is one example:  http://blogs.telerik.com/kevinbabcock/posts/09-04-24/connecting_the_dots_ado_net_data_services_and_telerik_reporting.aspx

from the above blog page:

The ReportParameter Collection editor will appear, which you can use to add a single parameter with the following properties – Name: Category; Type: Integer; UI.AllowBlank: False; UI.AvailableValues.DataMember: CategoryID; UI.AvailableValues.DisplayMember: CategoryName; UI.AvailableValues.ValueMember: CategoryID; UI.MultiValue: True; UI.Text: Category; UI.Visible: True.

0
Steve
Telerik team
answered on 17 Nov 2010, 05:55 PM
Hi Amy,

This functionality has been implemented in the Q1 2010 release, namely the following work item: Added support for retrieving parameter's label as well as its value in expressions.
As visible from the Using Report Parameters in Expressions help article, in the expression editor you can access the DisplayMember by using Label "keyword" e.g. "= Parameters.MyParameter.Label".

Kind regards,
Steve
the Telerik team
See What's New in Telerik Reporting in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
Tags
General Discussions
Asked by
Jaymie
Top achievements
Rank 1
Answers by
Steve
Telerik team
Amy
Top achievements
Rank 1
Share this question
or