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

[Solved] fill and Paging Radcombobox

4 Answers 375 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 20 May 2008, 04:42 AM

Hi
how to use paging ability for tamplate item(multi column) RadComboBox

i use from radcombobox that have a multi column ,Paging
but i have a problem with paging

Aspx

<rad:radcombobox   
        id="RadComboBox1"   
        runat="server"   
        Height="190px"   
        Width="420px"   
        EnableLoadOnDemand="True"   
        AllowCustomText="True"                              
        ShowMoreResultsBox="True"   
        ItemRequestTimeout="500"   
        MarkFirstMatch="true"   
        DropDownWidth="423px"   
        HighlightTemplatedItems="true"   
        OnItemDataBound="RadComboBox1_ItemDataBound"   
        OnItemsRequested="RadComboBox1_ItemsRequested" 
        > 
        <HeaderTemplate> 
            <table style="width: 415px; text-align: left">  
                <tr> 
                    <td style="width: 125px;">  
                        Product ID  
                    </td> 
                    <td style="width: 125px;">  
                        Product Name  
                    </td> 
                    <td style="width: 125px;">  
                        Unit Price  
                    </td> 
                </tr> 
            </table> 
        </HeaderTemplate> 
        <ItemTemplate> 
            <table style="width: 415px; text-align: left">  
                <tr> 
                    <td style="width: 125px;">  
                        <%# DataBinder.Eval(Container.DataItem, "ProductID")%> 
                    </td> 
                    <td style="width: 125px;">  
                        <%# DataBinder.Eval(Container.DataItem, "ProductName")%> 
                    </td> 
                    <td style="width: 125px;">  
                        <%# DataBinder.Eval(Container.DataItem, "UnitPrice")%> 
                    </td> 
                </tr> 
            </table> 
        </ItemTemplate> 
        </rad:radcombobox> 

Cs

 public DataTable GetDataTable(string Query)  
    {  
        SqlDataAdapter DaQuery = new SqlDataAdapter();  
        DaQuery.SelectCommand = new SqlCommand(Query, ObjCn);  
 
        DataTable myDataTable = new DataTable();  
 
        if (DaQuery.SelectCommand.Connection.State == ConnectionState.Closed) { ObjCn.Open(); }  
        try 
        {  
            DaQuery.Fill(myDataTable);  
        }  
        finally 
        {  
            if (DaQuery.SelectCommand.Connection.State == ConnectionState.Open) { ObjCn.Close(); }  
        }  
 
        return myDataTable;  
    }  
 
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (!Page.IsPostBack)  
        {  
            LoadSupervisors();  
        }  
    }  
 
    DataView Dv = new DataView();  
    DataTable Dt = new DataTable();  
 
    private void LoadSupervisors()  
    {  
        if (Cache["Dv"] == null)  
        {  
 
            DataView dv1 = new DataView(this.GetDataTable("SELECT * from Products"));  
           Cache["Dv"] = dv1;          
        }  
           Dv = (DataView)Cache["Dv"];  
    }  
 
      
    protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)  
    {  
 
        LoadSupervisors();  
        RadComboBox1.Items.Clear();
        RadComboBox1.DataSource = Dv;  
        RadComboBox1.DataBind();  
             
    }  
 
    protected void RadComboBox1_ItemDataBound(object o, RadComboBoxItemDataBoundEventArgs e)  
    {  
        e.Item.Text = ((DataRowView)e.Item.DataItem)["ProductName"].ToString() + "; " + ((DataRowView)e.Item.DataItem)["ProductID"].ToString() + "; " + ((DataRowView)e.Item.DataItem)["UnitPrice"].ToString();  
    }  
 

when i click on a MoreResult button in a end of combobox popup
combo show doublicated  data

Thanks
Ali

4 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 23 May 2008, 07:47 AM
Hi Ali,

I examined your logic and noticed that it differs from the one shown in our online demo for this functionality: AutoComplete Callback from Dictionary, Combobox for ASP.NET. Please follow the guidelines described there in order to implement the functionality correctly.

Note that part of the code which determines which rows should be added to the list of existing Items in the RadComboBox - this is mandatory, so that only new rows are added to that list.

In your case, this part is missing. Adding it will fix the paging.

Sincerely yours,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ali
Top achievements
Rank 1
answered on 24 May 2008, 10:04 AM

Hi Simon 
i use from RadCombobox ItemTemplate
can i add item manually to RadCombobox
as RadCombobox Item

RadComboBox1.Items.Add(new RadComboBoxItem(rows[i]["word"].ToString(),rows[i]["word"].ToString() + "'"));  
 

Thanks
All the best
Ali

0
Ali
Top achievements
Rank 1
answered on 25 May 2008, 04:37 AM
Hello

Hi Simon   
i use from RadCombobox ItemTemplate   
can i add item manually to RadCombobox  
as RadCombobox Item  
 
 
 
RadComboBox1.Items.Add(new RadComboBoxItem(rows[i]["word"].ToString(),rows[i]["word"].ToString() + "'"));     
    
 
Thanks  
All the best  
Ali  
 

Can i add ItemTemplate manually to RadCombobox 
Like a Item

Thanks
Ali
 
0
Simon
Telerik team
answered on 27 May 2008, 01:32 PM
Hi Ali,

Yes, you can add an Item manually and still benefit from the ItemTemplate. However, you should call the DataBind() method of the added Item or of the RadComboBox in order for the Template to be instantiated and the binding expressions evaluated.

What is more, since you do not have a DataItem, in case you manually add Items to RadComboBox, you could evaluate only the properties of each Item: Text, Value, Custom Attributes, etc.

In other words, instead of

<%# DataBinder.Eval(Container.DataItem, "ProductName")%> 

you could only write

<%# DataBinder.Eval(Container, "Text")%> 

which will bind the Text property of that Item.

Please see this topic for more information - Data Binding in Templates.

Kind regards,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Ali
Top achievements
Rank 1
Answers by
Simon
Telerik team
Ali
Top achievements
Rank 1
Share this question
or