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

Customizing with GridTemplateColumn from Code Behind

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Den
Top achievements
Rank 1
Den asked on 13 Nov 2008, 07:00 PM
I need to be able to create something like this
http://www.telerik.com/help/aspnet-ajax/grdcustomizewithgridtemplatecolumn.html

From the code behind but I couldn't find headerTemplate property

RadGrid1.Columns(1).headerTemplate()


Please help
Den

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Nov 2008, 06:21 AM
Hello Den,

You can try out the following code to add multi rows to the HeaderTemplate for a TemplateColumn from code behind.
aspx:
 <telerik:GridTemplateColumn UniqueName="Template" > 
        <ItemTemplate> 
           <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
        </ItemTemplate>         
 </telerik:GridTemplateColumn> 

cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridHeaderItem) 
        { 
            GridHeaderItem header = (GridHeaderItem)e.Item;             
            Table table = new Table(); 
            TableRow row = new TableRow(); 
            TableCell cell = new TableCell();             
            Label lbl = new Label(); 
            lbl.Text = "JAN"
            cell.Controls.Add(lbl); 
            cell.Width = Unit.Percentage(100); 
            row.Controls.Add(cell);             
            table.Rows.Add(row); 
            table.Width = Unit.Percentage(100); 
            header["Template"].Controls.Add(table); 
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Den
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or