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

Simple ComboBox Behavior Issue

1 Answer 26 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 11 May 2012, 06:56 PM
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"
                   ViewStateMode="Enabled"
               EmptyMessage="State/Region" ExpandAnimation-Type="InOutQuad"
                                   BorderStyle="None" AppendDataBoundItems="True"
                                   DataSourceID="sqlStates" DataTextField="StateName"
                                   DataValueField="StateAbbr" CausesValidation="False">
               <Items>
               <telerik:RadComboBoxItem runat="server" Text="" Selected="true"
                       Value="" />
               </Items>
                       <ExpandAnimation Type="InOutQuad" />
           </telerik:RadComboBox>

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 ASP.net DropDownList and tie it to the same SQL data source, it works fine.
 
End Sub

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 May 2012, 12:02 PM
Hello Shawn,

I cannot reproduce the issue at my end. The SelectedValue will return the corresponding value for DataTextField. Here is the sample code.
VB:
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

Thanks,
Shinu.
Tags
General Discussions
Asked by
Shawn
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or