I have a combo box that I populate with with searchig a db once the user has typed at least two characters. How do I make sure that the user actually selects one of the returned items and doesn't simply type a few characters and move on? I need the value in the control to be one of the returned items whether the user types it all the way out or selects an option after the LoadOnDemand. Is there a property I am not using correctly or a client side script approach?
<telerik:RadComboBox ID="cboAccounts" runat="server" Width="300" Font-Size="11px"
EnableLoadOnDemand="true" AllowCustomText="false" MarkFirstMatch="true" EnableTextSelection="true"
EmptyMessage="Search/Select an Account" IsCaseSensitive="false" EnableItemCaching="true"
LoadingMessage="Fetching matching items..." ShowDropDownOnTextboxClick="false"
Height="100" AutoPostBack="true" CausesValidation="false">
<ExpandAnimation Duration="200" />
<CollapseAnimation Duration="200" />
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="cboAccounts"
runat="server" ErrorMessage="*" CssClass="ErrorMsg"></asp:RequiredFieldValidator>
Private Sub cboAccounts_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles cboAccounts.ItemsRequested
If e.Text <> String.Empty And Len(e.Text) >= 2 Then
Dim dtbl As DataTable = SearchAccounts("", e.Text, Url.GetPath(), ActiveUser.UserID)
For Each row As DataRow In dtbl.Rows
Dim item As New RadComboBoxItem(row("account_name").ToString() & " (" & row("account_type").ToString() & ")", row("account_no").ToString())
cboAccounts.Items.Add(item)
Next
End If
End Sub
Private Function SearchAccounts(ByVal top As String, ByVal prefixText As String, ByVal path As String, ByVal user_id As String) As DataTable
Dim dvw As DataTable
With New VBDataLayer.SqlServer(conStr)
.AddParameter("@top", top)
.AddParameter("@prefixText", prefixText)
.AddParameter("@path", path)
.AddParameter("@user_id", user_id)
.AddParameter("@version", CStr(Session("version")))
dvw = .RunProc("wsp_web_Search_Accounts2", "Accounts").Tables(0)
End With
Return dvw
End Function