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

ComboBox SelectedValue Incorrect

1 Answer 119 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Lynn
Top achievements
Rank 2
Lynn asked on 11 Apr 2010, 12:35 AM
I have used Telerik products for years, including the combobox.  But I am having a problem I cannot figure out.

I have a combo box that is populated from an arraylist at page load...

===============================================================================
Page load event code to load combo box:

nopCommTopic.Items.Clear()

RCBI =

New RadComboBoxItem()

 

RCBI.Text =

"Select a topic..." & ",0"

 

RCBI.Value = 0

RCBI.Selected =

True

 

nopCommTopic.Items.Add(RCBI)

 

For Each Nop_Topic_Data In Nop_Topic_Arry

 

    RCBI =

New RadComboBoxItem()

 

    RCBI.Text = Nop_Topic_Data.Name &

", " & Nop_Topic_Data.TopicID.ToString

 

    RCBI.Value = Nop_Topic_Data.TopicID

    nopCommTopic.Items.Add(RCBI)

 

Next

 

 

 

 

 


===============================================================================



The page contains a button for execution after the user selects an item from the above combo box.  After the button is clicked, the code retrieves the selected value from the combo box and then continues processing.  The problem is that the selected value test (see code immediately below) always gets a 0 for the selectedvalue no matter which item in the combo box is selected.  It also does not matter how many different entries in the combo box that you select before pressing the processing button.

The .aspx page code for the combo is shown further below.  It's pretty simple.


===============================================================================
button click event code:

 

 

' Verify that the user did select a topic to translate and save it if they did

 

 

Dim iTopic As Integer = 0

 

 

If Me.nopCommTopic.SelectedValue = 0 Then

 

 

Me.PageErrors.Text = "You must select a topic to translate from the list!"

 

 

Exit Sub

 

 

End If

 

iTopic = nopCommTopic.SelectedValue
===============================================================================

===============================================================================
related code from .aspx page:

 

<

 

telerik:RadComboBox ID="nopCommTopic" Skin="NeoClassic" EnableEmbeddedSkins="false" runat="server"></telerik:RadComboBox>

 

 

<br />

 

 

<br />

 

 

<asp:Button ID="TranslateTopic" runat="server" Text="Translate Selected Topic" />

 

 

 

 

 

===============================================================================

Can you help me figure out what is wrong?

Thanks in advance!  I feel so stupid, but I cannot figure this out.  I must be missing something really basic!

Lynn

1 Answer, 1 is accepted

Sort by
0
Lynn
Top achievements
Rank 2
answered on 11 Apr 2010, 02:26 PM
I am closing this item...I did figure this out and it was about as stupid as I was afraid it would be.  The combo box population was occurring in the Page Load event WITHOUT being "inside" the Page.IsPostback test, so it was clearing/re-populating the combo box before the Button Click event code was processed.  Duh...
Tags
ComboBox
Asked by
Lynn
Top achievements
Rank 2
Answers by
Lynn
Top achievements
Rank 2
Share this question
or