I have a RadCombobox where in the first name textbox if I type a letter...it shows me list of users that begin with that letter.
I have server side code rcbFirstName_itemsrequested that pulls the data out of the db and displays it.
The drop down is working fine. However I do not understand how to get rid of the empty Combo box item if there are no matches. Also, how to get rid of the down arrow if there are no matches.
What do I need to do if I don't want to show the drop down if there are no matches.
Please advice!
Thanks!
<
telerik:RadComboBox
Visible
=
"false"
Skin
=
"Vista"
TabIndex
=
"10"
ID
=
"rcbLastName"
runat
=
"server"
AllowCustomText
=
"true"
Width
=
"200px"
ShowToogleImage="false" EnableOverlay
=
"true"
ShowDropDownOnTextboxClick
=
"false"
DropDownWidth
=
"200px"
MaxLength
=
"20"
CausesValidation
=
"false"
EnableLoadOnDemand
=
"true"
EnableScreenBoundaryDetection
=
"false"
ExpandDirection
=
"Up"
EnableVirtualScrolling
=
"true"
ShowMoreResultsBox
=
"true"
AutoPostBack
=
"True"
OnClientItemsRequesting
=
"OnClientItemsRequesting"
OnClientDropDownOpening
=
"OnClientDropDownOpening"
OnItemsRequested
=
"rcbLastName_ItemsRequested"
OnSelectedIndexChanged
=
"rcbBarNumber_SelectedIndexChanged"
ItemsPerRequest
=
"5"
>
I have server side code rcbFirstName_itemsrequested that pulls the data out of the db and displays it.
if (!String.IsNullOrEmpty(e.Text))
{
rcbLastName.ClearSelection();
NameValueCollection nvc = new NameValueCollection();
nvc.Add("LastName", e.Text);
DataTable accounts = DB.ExecuteDataTable("usp_AccountsGetByLastName", nvc);
int itemOffset = e.NumberOfItems;
int endOffset = Math.Min(itemOffset + rcbLastName.ItemsPerRequest, accounts.DefaultView.Count);
e.EndOfItems = endOffset == accounts.DefaultView.Count;
for (int i = itemOffset; i <
endOffset
&& i < accounts.DefaultView.Count; i++)
{
string
data
=
accounts
.DefaultView[i]["FullName"].ToString();
if (!String.IsNullOrEmpty(accounts.DefaultView[i]["Address1"].ToString()))
{
data += " - " + accounts.DefaultView[i]["Address1"].ToString() + " ";
if (!String.IsNullOrEmpty(accounts.DefaultView[i]["Address2"].ToString()))
data += accounts.DefaultView[i]["Address2"].ToString() + " ";
data += accounts.DefaultView[i]["City"].ToString() + " " + accounts.DefaultView[i]["State"].ToString() + " " + accounts.DefaultView[i]["Zip"].ToString();
}
rcbLastName.Items.Add(new RadComboBoxItem(data, accounts.DefaultView[i]["AccountID"].ToString()));
}
if (accounts.DefaultView.Count <= 0)
e.Message
=
"No matches"
;
else
e.Message
=
String
.Format("Items <b>1</
b
>-<
b
>{0}</
b
> out of <
b
>{1}</
b
>", endOffset, accounts.DefaultView.Count);
}
The drop down is working fine. However I do not understand how to get rid of the empty Combo box item if there are no matches. Also, how to get rid of the down arrow if there are no matches.
What do I need to do if I don't want to show the drop down if there are no matches.
Please advice!
Thanks!