Hi all,
I am using radcombo with OnItemsRequested event,
I want to add one default item say <Unknown> in to combo,
i tried to add as below, but it displays <Unknown> item many times. Item is added in each request.
<telerik:RadComboBox ID="rcbBeginPeriod" runat="server" |
Width="250px" Height="100px" Skin="Office2007" |
AllowCustomText="false" |
ShowToggleImage="true" |
ShowMoreResultsBox="True" |
EnableLoadOnDemand="True" |
MarkFirstMatch="True" |
OnItemsRequested="rcbBeginPeriod_ItemsRequested" |
EnableVirtualScrolling="true" |
> |
</telerik:RadComboBox> |
protected void rcbBeginPeriod_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e) |
{ |
try |
{ |
EventInfo objEventInfo = new EventInfo(); |
List<ctblPeriod> resultSet = null; |
resultSet = objEventInfo.GetAllQuarterPeriods(e.Text); |
try |
{ |
int itemsPerRequest = PRESCONSTANTS.COMBO_ITEMS_PER_REQUEST; |
int itemOffset = e.NumberOfItems; |
int endOffset = itemOffset + itemsPerRequest; |
if (endOffset > resultSet.Count) |
{ |
endOffset = resultSet.Count; |
} |
if (endOffset == resultSet.Count) |
{ |
e.EndOfItems = true; |
} |
else |
{ |
e.EndOfItems = false; |
} |
for (int i = itemOffset; i < endOffset; i++) |
{ |
rcbBeginPeriod.Items.Add(new RadComboBoxItem(resultSet[i].Period, resultSet[i].ID.ToString())); |
} |
if (resultSet.Count > 0) |
{ |
lblBeginPeriodID.Text = ""; |
e.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), resultSet.Count.ToString()); |
} |
else |
{ |
lblBeginPeriodID.Text = ""; |
e.Message = "No matches"; |
} |
} |
catch |
{ |
lblBeginPeriodID.Text = ""; |
e.Message = "No matches"; |
} |
finally |
{ |
if (!rcbBeginPeriod.Items.Contains(new RadComboBoxItem("<Unknown>", "-1"))) |
rcbBeginPeriod.Items.Add(new RadComboBoxItem("<Unknown>", "-1")); |
} |
} |
catch (Exception ex) |
{ |
} |
} |
Please help me to solve this problem.
Thanks
Amol