This is a migrated thread and some comments may be shown as answers.

Not answered Doubling of represented values in combobox

3 Answers 72 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Anton
Top achievements
Rank 1
Anton asked on 28 Nov 2008, 04:03 PM
Hello!
The problem is - if I open combobox with selected value and click "ShowMoreResults" arrow or perform virtual scroll down, items with the same text as selected one appears in list. At the ItemsRequested handler number of items remains as it expected.
How can I prevent the behaviour described above?

Controls version - 2008.3.1016.35
Here the test to illustrate issue:
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Test.WebApplication.test" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title></title
</head> 
<body> 
 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
 
    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> 
    </form> 
</body> 
</html> 
 
CS
using System; 
using System.Data; 
using Telerik.Web.UI; 
 
namespace Test.WebApplication 
    public partial class test : System.Web.UI.Page 
    { 
        public static DataTable currencyTable; 
        protected RadComboBox RadCombobox1; 
 
 
        protected void Page_Init(object sender, EventArgs e) 
        { 
            RadCombobox1 = new RadComboBox(); 
 
            RadCombobox1.AllowCustomText = false
            RadCombobox1.EnableItemCaching = true
            RadCombobox1.AutoPostBack = true
 
            RadCombobox1.IsCaseSensitive = false
            RadCombobox1.SortCaseSensitive = false
            RadCombobox1.Filter = RadComboBoxFilter.Contains; 
            RadCombobox1.EnableLoadOnDemand = true
            RadCombobox1.EnableVirtualScrolling = true
            RadCombobox1.ShowMoreResultsBox = true
            RadCombobox1.ShowDropDownOnTextboxClick = false
 
            RadCombobox1.ItemsRequested += RadCombobox1_ItemsRequested; 
 
            PlaceHolder1.Controls.Add(RadCombobox1); 
        } 
 
        private void RadCombobox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) 
        { 
             
        } 
 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!IsPostBack) 
            { 
                currencyTable = CreateCurrencyTable(); 
 
                RadCombobox1.DataTextField = "name"
                RadCombobox1.DataValueField = "id"
                RadCombobox1.DataSource = currencyTable; 
                RadCombobox1.DataBind(); 
            } 
        } 
 
        protected DataTable CreateCurrencyTable() 
        { 
            var table = new DataTable(); 
            DataRow row; 
            DataColumn column; 
 
            column = new DataColumn(); 
            column.DataType = System.Type.GetType("System.Int32"); 
            column.ColumnName = "id"
            column.ReadOnly = false
            column.Unique = true
            table.Columns.Add(column); 
 
            column = new DataColumn(); 
            column.DataType = System.Type.GetType("System.String"); 
            column.ColumnName = "name"
            column.ReadOnly = false
            column.Unique = false
            table.Columns.Add(column); 
 
            row = table.NewRow(); 
            row["name"] = "RUR"
            row["id"] = 1; 
            table.Rows.Add(row); 
 
            row = table.NewRow(); 
            row["name"] = "USD"
            row["id"] = 2; 
            table.Rows.Add(row); 
 
            row = table.NewRow(); 
            row["name"] = "EURO"
            row["id"] = 3; 
            table.Rows.Add(row); 
 
 
            return table; 
        } 
 
 
    } 
    
 


3 Answers, 1 is accepted

Sort by
0
Anton
Top achievements
Rank 1
answered on 01 Dec 2008, 01:32 PM
Can anybody answer?
0
Accepted
Yana
Telerik team
answered on 01 Dec 2008, 03:57 PM
Hello Anton,

You can use the following code snippet in RadCombobox1_ItemsRequested method:

RadCombobox1.Items.Clear();  
e.EndOfItems = true

You can also check our online example which demonstrates how to use Load On Demand mechanism of RadComboBox.

Kind regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Anton
Top achievements
Rank 1
answered on 01 Dec 2008, 07:01 PM
Hello Yana,

RadCombobox1.Items.Clear();  helps. Thank you.
The meaning of e.EndOfItems is mystery for me. Can't see difference in work with and without it's usage.
Tags
ComboBox
Asked by
Anton
Top achievements
Rank 1
Answers by
Anton
Top achievements
Rank 1
Yana
Telerik team
Share this question
or