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

[Solved] Changing itemtemplate of a radgrid dinamically

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ronald Fallas Rojas
Top achievements
Rank 1
Ronald Fallas Rojas asked on 25 Jun 2008, 12:01 AM
Hi, in the examples I found how to define the column template of a radgrid for ajax in design time, but I didn't find how to change the templates dynamically in code behind, Is this possible?

thx

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jun 2008, 05:08 AM
Hi,

Try the following code snippet.

ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol"
                     <ItemTemplate> 
                         <asp:Label ID="Label2" runat="server" Text="Click"></asp:Label> 
                     </ItemTemplate> 
                    </telerik:GridTemplateColumn> 

CS:
 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            item["TempCol"].Controls.Clear(); 
 
            TextBox txtbx = new TextBox(); 
            txtbx.ID = "TextBox1"
            item["TempCol"].Controls.Add(txtbx); 
        } 
   } 

Thanks
Shinu.
Tags
Grid
Asked by
Ronald Fallas Rojas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or