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

ComboBox doesn't work like a DropDownList

2 Answers 68 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Chase Florell
Top achievements
Rank 1
Chase Florell asked on 19 Sep 2008, 05:01 AM
I am fighting with the combo box and am almost ready to give up.

I need to be able to retrieve the values but it does not seem to work like the DropDownList Does... what am I doing wrong?

This part works fine
            Dim PagesDC As New Dal.icms_PagesDataContext  
            Dim ParentPages = PagesDC.icms_Pages_GetParentPages()  
            ddlParentPage.DataSource = ParentPages  
            ddlParentPage.DataTextField = "MenuName" 
            ddlParentPage.DataValueField = "ID" 
            ddlParentPage.DataBind()  
            ddlParentPage.Items.Insert(NothingNew RadComboBoxItem("[main menu]")) 

But this is throwing an error
    Protected Sub btnCreate_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnCreate.Click  
 
        Dim _UserName As String = Page.User.Identity.Name  
        Dim _isPublished As Boolean = False 
        If chkPublished.Checked = True Then _isPublished = True 
        Dim _ParentPage As Integer = Nothing 
 
        If Convert.ToInt32(ddlParentPage.SelectedItem.Value) <> Nothing Then _  
        _ParentPage = Convert.ToInt32(ddlParentPage.SelectedItem.Value)  
 
        Dim PagesDC As New Dal.icms_PagesDataContext  
        Dim insert = PagesDC.icms_Pages_CreateNewPage(_ParentPage, _  
                                                      RadComboBox1.SelectedItem.Value, _  
                                                      txtMenuOrder.Text, _  
                                                      txtMenuName.Text, _  
                                                      txtTitle.Text, _  
                                                      txtMetaKeywords.Text, _  
                                                      txtMetaDescription.Text, _  
                                                      _UserName, _  
                                                      _isPublished)  
        PagesDC.SubmitChanges()  
    End Sub 

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 99:         Dim _ParentPage As Integer = Nothing
Line 100:
Line 101: If Convert.ToInt32(ddlParentPage.SelectedItem.Text) <> "[main menu]" Then _
Line 102: _ParentPage = Convert.ToInt32(ddlParentPage.SelectedItem.Value) Line 103:

Source File: D:\Development\Visual Studio\xxxxxxx.com\App_Windows\Admin_Controls\Pages.ascx.vb    Line: 101

2 Answers, 1 is accepted

Sort by
0
-DJ-
Top achievements
Rank 1
answered on 20 Sep 2008, 02:58 PM
Hello Chase,

Looks to me like you are trying to convert a string into an integer:
Is the
    ddlParentPage.SelectedItem.Text
numeric?

The error messages seems to indicate it isn't.

Regards,
-DJ-
0
Atanas Korchev
Telerik team
answered on 22 Sep 2008, 07:35 AM
Hello,

Indeed it seems you should be using the Value property instead of the Text of the selected item. The same behavior should be reported by the DropDownList as well.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Chase Florell
Top achievements
Rank 1
Answers by
-DJ-
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or