ComboBox doesn't work like a DropDownList

3 posts, 0 answers
  1. Chase Florell
    Chase Florell avatar
    257 posts
    Member since:
    Apr 2005

    Posted 19 Sep 2008 Link to this post

    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.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, _  
        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\\App_Windows\Admin_Controls\Pages.ascx.vb    Line: 101
  2. -DJ-
    -DJ- avatar
    263 posts
    Member since:
    Oct 2004

    Posted 20 Sep 2008 Link to this post

    Hello Chase,

    Looks to me like you are trying to convert a string into an integer:
    Is the

    The error messages seems to indicate it isn't.

  3. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 22 Sep 2008 Link to this post


    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.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top