Adding itemtemplae dynamically in a radcombobox in a user control

2 posts, 0 answers
  1. Tanya
    Tanya avatar
    10 posts
    Member since:
    Apr 2014

    Posted 04 Jun 2014 Link to this post

    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: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">
                            <telerik:GridTemplateColumn DataField="LanCd">
                                    <img src="<%#DataBinder.Eval(Container.DataItem, "LanImg")%>" alt="ASP.NET hosting" />
                            <telerik:GridTemplateColumn DataField="LanCd">
                                <telerik:RadComboBox ID="RadComboBoxLang" runat="server"   EnableLoadOnDemand="true"  EnableEventValidation="true" AllowCustomText="true"   AppendDataBoundItems="true">
                                                     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: but as my radcombobox is in user control I can find it in Page_Init event

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Jun 2014 in reply to Tanya Link to this post

    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.
Back to Top