I am using a RadComboBox with EnableLoadOnDemand="true", and OnItemsRequested="brand_ItemsRequested" - I want to add a
default item that appears at the top of the list, so I have added
comboBrand.Items.Insert(0, new RadComboBoxItem("All Brands", "0"));
The trouble is, each time more results load and appends to the list, "All Brands" is also appended to the results that are returned, so it appears every 12th row. How can I insert just a single default value at the top of the list?
EDIT:
I tried wrapping some logic around the the comboBrand.items.insert to check for the item before inserting the default item, but multiple items are still being added:
protected void brand_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e) |
{ |
DataTable data = GetData(e.Text); |
int itemOffset = e.NumberOfItems; |
int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count); |
e.EndOfItems = endOffset == data.Rows.Count; |
for (int i = itemOffset; i < endOffset; i++) |
{ |
comboBrand.Items.Add(new RadComboBoxItem(data.Rows[i]["Name"].ToString(), data.Rows[i]["Name"].ToString())); |
} |
comboBrand.Items.Insert(0, new RadComboBoxItem("All Brands", "0")); |
e.Message = GetStatusMessage(endOffset, data.Rows.Count); |
} |
<telerik:RadComboBox ID="comboBrand" AppendDataBoundItems="true" LoadingMessage="Retrieving Brands..." AutoPostBack="true" runat="server" Width="250px" Height="150px" |
EnableLoadOnDemand="true" ShowMoreResultsBox="true" ShowWhileLoading="false" |
EnableVirtualScrolling="true" OnSelectedIndexChanged="comboBrand_SelectedIndexChanged" |
OnItemsRequested="brand_ItemsRequested"> |
</telerik:RadComboBox> |
The trouble is, each time more results load and appends to the list, "All Brands" is also appended to the results that are returned, so it appears every 12th row. How can I insert just a single default value at the top of the list?
EDIT:
I tried wrapping some logic around the the comboBrand.items.insert to check for the item before inserting the default item, but multiple items are still being added:
if (!comboBrand.Items.Contains(new RadComboBoxItem("All Brands", "All Brands"))) |
{ |
comboBrand.Items.Insert(0, new RadComboBoxItem("All Brands", "All Brands")); |
} |