Hightlight Selected Value in Combobox from textbox

2 posts, 0 answers
  1. Joe Riley
    Joe Riley avatar
    6 posts
    Member since:
    Mar 2010

    Posted 08 Sep 2010 Link to this post

    Trying to implement a RadComboBox that updates as the user types.  There is no problem with the RadComboBox  and populating it with the appropriate data.  Where I am running into a problem is selecting a value if a user tried finding a value via a RadTextBox.  The search performs properly but I need it to select the record found and update a few additional fields. 

    See Comment:
    'If sASI_Num <> "" then update Label1 & Have _ddCUName be updated with the value selected as it properly is returned by the stored procedure just not selected.

    See Code.
        <telerik:RadTextBox Runat="server" id="_txtCUNum" Width="50px">
        <asp:Label ID="Label1" runat="server" Text="Label" Font-Bold="True" ForeColor="Green"></asp:Label>
    <td>CU Name:
        <telerik:RadComboBox id="_ddCUName" Runat="server" Width="450px" EmptyMessage="Type a Credit Union Name" HighlightTemplatedItems="true" height="100px" EnableLoadOnDemand="true" OnItemsRequested="RadComboBoxProduct_ItemsRequested">
                        <TR><TD>CU Name</TD><TD>City</TD><TD>State</TD></TR>
                            <TD><%#DataBinder.Eval(Container, "Text")%></TD>
                            <TD><%#DataBinder.Eval(Container, "Attributes['City']")%></TD>
                            <TD><%#DataBinder.Eval(Container, "Attributes['State']")%></TD>
       Protected Sub RadComboBoxProduct_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs)
            Dim sAsi_Num As Object
            If Me._txtCUNum.text = "" Then
                sAsi_Num = DBNull.Value
                sAsi_Num = Me._txtCUNum.text
            End If
                Dim ocmd As New SqlCommand("sp_getCUSearch", oConn)
                ocmd.CommandType = CommandType.StoredProcedure
                With ocmd.Parameters
                    .Add(New SqlParameter("@asi_num", sAsi_Num))
                    .Add(New SqlParameter("@SearchStr", e.Text))
                End With
                reader = ocmd.ExecuteReader()
                If reader.HasRows Then
                    While reader.Read
                        Dim item As New RadComboBoxItem()
                        item.Text = DirectCast(reader("cuName"), String)
                        item.Value = reader("asi_num").ToString()
                        Dim sCity As String = DirectCast(reader("City"), String)
                        Dim sState As String = DirectCast(reader("State_ID"), String)
                        item.Attributes.Add("City", sCity.ToString())
                        item.Attributes.Add("State", sState.ToString())
                        'item.Value += ":" + unitPrice.ToString()
                    End While
    'If sASI_Num <> "" then update Label1 & Have _ddCUName be updated with the value selected as it properly is returned by the stored procedure just not selected.
                End If
            Catch ex As Exception
            End Try
        End Sub
  2. Simon
    Simon avatar
    2281 posts

    Posted 13 Sep 2010 Link to this post

    Hi Joe Riley,

    Your issue originates from the fact that during Load On Demand requests only the only updated control is the RadComboBox itself. Moreover, only its state and a part of it is sent back and forth to the server.

    So you cannot access other controls' values that have been changed on the client. Luckily you can use the Context object as a workaround for this limitation.

    Secondly you can update the Label on the client, *after* the Load On Demand request returns from the server by handling the client-side ItemsRequested event.

    I hope these articles will help you resolve the issues.

    Sincerely yours,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top