Can't select item

2 posts, 0 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 16 Aug 2011 Link to this post

    I have a rad combo box that I bind in my code with a data table. Whenever I select an item and then click out of the combo box, it doesn't keep the item I had picked selected. You can see my problem here . Just pick an item and then click out of the dropdown. Here is my aspx code

    <telerik:RadComboBox ID="salesInput" runat="server" Width="200px" MarkFirstMatch="true">

    here's my vb code behind and the function it calls
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If (Not Page.IsPostBack) Then
                'populate the dropdown
                Dim tableOfData As DataTable = MyFunctions.createCrewDeleteTable()
                salesInput.DataSource = tableOfData
                salesInput.DataTextField = "Salesman"
                salesInput.DataValueField = "CrewId"
            End If
    End Sub

    And the function
        'this function gets the data for the crew dropdown
        'this sub returns a data table to bind to the dropdown
        Public Shared Function createCrewDeleteTable()
            'a new data table
            Dim table As DataTable = New DataTable()
            Dim type
            'my sql connection
            Dim myConn As New Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("connection").ToString)
            'the name of the stored procedure
            Dim strSQL = "select FirstName+' '+LastName as Name, CrewType, CrewId from Crew where Deleted <> 'yes' " & _
            "AND crewid > 1 order by LastName, Firstname"
                Dim readCommand As New Data.SqlClient.SqlCommand(strSQL, myConn)
                'while we have rows from the stored procedure
                'we will add them to a data table
                Dim cdr As SqlDataReader = readCommand.ExecuteReader()
                While cdr.Read()
                    If (cdr(1).ToString = "3") Then
                        type = "Salesman"
                    ElseIf cdr(1).ToString = "2" Then
                        type = "Crew Chief"
                        type = "Crew"
                    End If 'if cdr(2)
                    If (cdr.Item(0).ToString <> "") Then
                        table.Rows.Add(New String() {cdr.Item(0) & " - " & type, cdr.Item(1)})
                    End If
                End While 'while cdr.Read()
            Catch ex As Exception
            End Try
            Return table
    End Function

  2. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010

    Posted 17 Aug 2011 Link to this post

    This issue can occur when there are items with same values in combobox - please take a look at this article.
  3. DevCraft R3 2016 release webinar banner
Back to Top