I am using Load on Demand with ShowMoreResults and I am binding to the combobox on the intitial Page_Load so the first page of results is in the combobox before a user actually requests them. I am pretty sure that this initial binding on the page_load is what is causing the problem, but it is necessary for my requirements.
When I click the more results button, the ItemsRequested event is fired off and I add more items to the combobox. When the results are finished being loaded into the combobox, I get the original first page of results with the second page after it, then the first page of results again.
Why am I getting these repeat items? How can I stop these repeat items from being added. It has something to do with the fact that I am making this initial load. I noticed when the ItemsRequested event gets called and I don't make that initial load, the combobox.items.count always starts off at 0 when the ItemsRequested event begins, but when I make that initial load, the count is always the size of my first page 100 when it begins.
Here is my aspx code for the combobox:
Here is my page load event:
When I click the more results button, the ItemsRequested event is fired off and I add more items to the combobox. When the results are finished being loaded into the combobox, I get the original first page of results with the second page after it, then the first page of results again.
Why am I getting these repeat items? How can I stop these repeat items from being added. It has something to do with the fact that I am making this initial load. I noticed when the ItemsRequested event gets called and I don't make that initial load, the combobox.items.count always starts off at 0 when the ItemsRequested event begins, but when I make that initial load, the count is always the size of my first page 100 when it begins.
Here is my aspx code for the combobox:
| <telerik:RadComboBox ID="testDdl" runat="server" Width="350px" Height="200px" DataTextField="DocumentId" DataValueField="MainId" Skin="Outlook" AllowCustomText="true" ShowToggleImage="true" MarkFirstMatch="true" OnItemsRequested="TestDdl_ItemsRequested" EnableLoadOnDemand="true" ShowMoreResultsBox="true" /> |
Here is my page load event:
| protected void Page_Load(object sender, EventArgs e) |
| { |
| Documents testDocuments = new Documents(); |
| for (int i = 0; i < 100; i++) |
| { |
| Document document = new Document(); |
| document.DocumentId = i.ToString(); |
| document.MainId = i; |
| testDocuments.Add(document); |
| } |
| testDdl.DataSource = testDocuments; |
| testDdl.DataBind(); |
| } |
Here is my ItemsRequested event:
| protected void TestDdl_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e) |
| { |
| int myTotalRecordCount = 1000; |
| const int itemsPerRequest = comparisonSetPageSize; |
| int itemOffset = e.NumberOfItems; |
| int endOffset = itemOffset + itemsPerRequest; |
| if (endOffset > myTotalRecordCount) |
| { |
| endOffset = myTotalRecordCount; |
| } |
| e.EndOfItems = endOffset == myTotalRecordCount; |
| for (int i = itemOffset; i < endOffset; i++) |
| { |
| RadComboBoxItem newnewItem = new RadComboBoxItem(i.ToString(), i.ToString()); |
| testDdl.Items.Add(newItem); |
| } |
| e.Message = "Items 1 - " + endOffset + " of " + myTotalRecordCount; |
| } |