This is a migrated thread and some comments may be shown as answers.
Can't set SelectValue in databound dropdownlist
1 Answer 6 Views
This is a migrated thread and some comments may be shown as answers.
Art
Top achievements
Rank 1
Art asked on 10 Nov 2017, 07:02 PM

What I'm trying is so simple, but doesn't work

-----------------------------

Imports Telerik.WinControls.UI

Public Class frmListTest
  Private dtTest As DataTable   

    Private Sub frmListTest_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            fillDataTable(dtTest)  ' procedure fills the table from an Oracle database procedure

            myDropDownList.DataSource = dtTest

            myDropDownList.ValueMember = "VALUE_MEMBER"
            myDropDownList.DisplayMember = "DISPLAY_MEMBER"

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        myDropDownList.SelectedValue = 6  '  DOES NOT WORK
    End Sub

-------------------------------------

dtTemp structure
value_member     display_member
24                         Athletic Operations Building
1                           Camp Randall Stadium
34                         Camp Randall Stadium Misc.
22                         Cr Sports Center [shell] - Womens Hockey
37                         Goodman Diamond All Season Practice
6                           Goodman Softball Complex
23                         Kellner Hall 
2                           Kohl Center
35                         La Bahn Arena
4                           McClain Center

The dropdown list loads ok, but I can't select an item through the SelectedValue property.

What am I doing wrong, or not doing? 

Telerik V 2016.3.913.40

Visual Studio Pro V 14.0.25431.01

 

Later

Art


1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 13 Nov 2017, 09:34 AM
Hi Art,

This works fine on my side (see attached project). 

What can cause such issue is when you are storing the numbers as a string for example. So make sure that you are using the correct data type when setting the SelectedValue.

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Art
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or