Simple ComboBox Behavior Issue

2 posts, 0 answers
  1. Shawn
    Shawn avatar
    83 posts
    Member since:
    Jan 2009

    Posted 11 May 2012 Link to this post

    I have no idea why this would be, but it seems rather routine.

    I have a combobox that displays all of the US States, and it populates fine.

    <telerik:RadComboBox ID="StateList" Runat="server"
                   Skin="Windows7" Width="150px"
                   EmptyMessage="State/Region" ExpandAnimation-Type="InOutQuad"
                                       BorderStyle="None" AppendDataBoundItems="True"
                                       DataSourceID="sqlStates" DataTextField="StateName"
                                       DataValueField="StateAbbr" CausesValidation="False">
                   <telerik:RadComboBoxItem runat="server" Text="" Selected="true"
                           Value="" />
                           <ExpandAnimation Type="InOutQuad" />

    However, when I try to get the value from the btn_click event, it is empty.... why???

    Protected Sub btn_submit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btn_submit.Click
    Dim State as String = StateList.SelectedValue
    'shows empty every time
    'if I plug in a standard DropDownList and tie it to the same SQL data source, it works fine.
    End Sub

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 May 2012 Link to this post

    Hello Shawn,

    I cannot reproduce the issue at my end. The SelectedValue will return the corresponding value for DataTextField. Here is the sample code.
    Protected Sub Button1_Click(sender As Object, e As EventArgs)
        Dim value As String = StateList.SelectedValue
        'accessing selected value
        Dim value1 As String = StateList.SelectedItem.Text
        'accessing selected text
    End Sub

Back to Top