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

Adding itemtemplae dynamically in a radcombobox in a user control

1 Answer 40 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tanya
Top achievements
Rank 1
Tanya asked on 04 Jun 2014, 01:02 PM
I've got  one Radgrid and inside it's GridTemplateColumn I've got RAdComboBox

The problem is that all this is inside a user control

<%@ Control Language="C#" AutoEventWireup="true" Inherits="MvcBeaWeb.GridLanguageView" CodeFile="GridLanguageView.ascx.cs" %>
<%@ Import Namespace="MvcBeaWeb" %>
<%@ Register Assembly="Telerik.Web.UI" TagPrefix="telerik" Namespace="Telerik.Web.UI" %>


  
    <telerik:RadScriptManager
        ID="RadScriptManager1"   
        runat="server"   
      >
    </telerik:RadScriptManager>
  
  
        
            <telerik:RadGrid ID="RadGridLang" runat="server" AutoGenerateColumns="False"  EnableEmbeddedSkins="False"  RegisterWithScriptManager=false 
                 DataTextField="Descr" DataValueField="LanImg"
                Height="100%" Width="120px" AppendDataBoundItems="true" CellSpacing="0" GridLines="None" OnLoad="RadGridLang_Load">
                <MasterTableView>
                    <Columns>
                        <telerik:GridTemplateColumn DataField="LanCd">
                            <ItemTemplate>
                                <img src="<%#DataBinder.Eval(Container.DataItem, "LanImg")%>" alt="ASP.NET hosting" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="LanCd">
                            <ItemTemplate>
                            <telerik:RadComboBox ID="RadComboBoxLang" runat="server"   EnableLoadOnDemand="true"  EnableEventValidation="true" AllowCustomText="true"   AppendDataBoundItems="true">
                               
                                 
                            </telerik:RadComboBox>
                          
                                           
                              
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
                                  ---------------------------------------------------------------------------
                                                 Myquestion is can someone help me step by step how can I add dybnamically in my .cs code of my user control   an ItemTemplate to my radcombobox which should be an anchor element <a href="" >descr </a>
The innerHtml (descr)  I should get from my list which should be the datasource for my radcombobox;; 

I saw this example:   http://www.telerik.com/help/aspnet-ajax/combobox-templates-adding.html but as my radcombobox is in user control I can find it in Page_Init event


      

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Jun 2014, 08:31 AM
Hi Tanya,

At first the OnInit  event will fire, at that time controls inside the RadGrid is not ready so that it is not possible to access. The ItemTemplate should be initialized in the OnInit event of the page. This is needed as the template should be instantiated before RadComboBox items are initialized.  In your Scenario you can add the Controls inside the RadComboBox in OnItemDataBound event.

Let me know if you have any concern.
Thanks,
Shinu.
Tags
ComboBox
Asked by
Tanya
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or