Can't set SelectValue in databound dropdownlist

2 posts, 0 answers
  1. Art
    Art avatar
    55 posts
    Member since:
    Dec 2010

    Posted 10 Nov 2017 Link to this post

    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




  2. Dimitar
    Dimitar avatar
    2983 posts

    Posted 13 Nov 2017 Link to this post

    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.

    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.
Back to Top