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

[Solved] ItemTemplate binding not working using onitemrequest

2 Answers 137 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Gianluca
Top achievements
Rank 1
Gianluca asked on 16 Apr 2009, 02:37 PM
Hi,

i need a radcombobox populated by a class, on itemrequested

 protected void frmIdCliente_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)  
    {  
        string text = e.Text;  
        frmIdCliente.Items.Clear();  
        ANCLI0.PopolaRadCombo(ref frmIdCliente, text, "C", 10);  
    } 
On ANCLI0 class i have:
       public static void PopolaRadCombo(ref RadComboBox ComboBoxToPopulate, String Filter, String FLCLF, Int32 NumeroRisultati)  
        {  
            RadComboBoxItem Cliente;  
            ANCLI0 xxx = new ANCLI0();  
            Hashtable Hashclienti = xxx.Cerca(Filter.ToString(), NumeroRisultati, "OMBBG", FLCLF);  
            foreach (DictionaryEntry Entry in Hashclienti)  
            {  
                xxx = new ANCLI0(Entry.Key.ToString());  
                Cliente = new RadComboBoxItem();  
                Cliente.Text = xxx.DescrizioneCompleta;  
                Cliente.Value = Entry.Key.ToString();  
                Cliente.Attributes.Add("Indirizzo", xxx.IndirizzoCompleto);  
                //se cliente non accetta ordini lo evidenzio in rosso  
                if (xxx.ANCLI0_ACCOR == "NO")  
                {  
                    Cliente.BackColor = System.Drawing.Color.Red;  
                    Cliente.Enabled = false;  
                }  
                ComboBoxToPopulate.Items.Add(Cliente);  
            }  
            ComboBoxToPopulate.SortItems();  
        } 

if my combobox is a simple one (without itemtemplates), it works fine, but if i have templated items like following:
<telerik:RadComboBox ID="frmIdCliente" runat="server" AllowCustomText="True" EnableLoadOnDemand="True" 
               HighlightTemplatedItems="true" MarkFirstMatch="True"   
                OnItemsRequested="frmIdCliente_ItemsRequested"   
                SkinsPath="~/RadControls/ComboBox/Skins" Width="150px" Skin="WebBlue">  
 
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
     
<ItemTemplate> 
       <table style="width:300px;border-bottom:1px solid black;padding:5px 0 5px 0;" cellspacing = 0 cellpadding = 0 class="normal">  
           <tr> 
               <td style="width:150px; text-align: left">  
                   <asp:Label ID="Label1" runat="server" Text='<%# Eval("Text") %>'></asp:Label> 
                   </td> 
 
               <td style="width:150px; text-align: left">  
                   <%# DataBinder.Eval(Container.DataItem, "Text")%> 
                   <%# DataBinder.Eval(Container, "Attributes['Indirizzo']")%> 
                   <%# DataBinder.Eval(Container.DataItem, "Attributes 'Indirizzo']")%> 
                   <%# Container.Attributes["Indirizzo"].ToString() %> 
               </td> 
           </tr> 
        </table> 
 </ItemTemplate>    
 </telerik:RadComboBox> 
when i click on my combo, it don't show me values on its rows.... i think there's a problem with databindings, i try differents databindings (see code above), but it neve shows me "Text" or "Indirizzo" Values...

Someone coul help me??

thanks in advance! 


2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 16 Apr 2009, 04:43 PM
Hi Gianluca,

Data binding expressions are evaluated only during databinding. Please call the DataBind method of RadComboBox at the end of the ItemsRequested event.

Best wishes,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Gianluca
Top achievements
Rank 1
answered on 17 Apr 2009, 12:51 PM
Thank's , it works :-)



Tags
ComboBox
Asked by
Gianluca
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Gianluca
Top achievements
Rank 1
Share this question
or