RadGrid for ASP.NET

RadGrid Send comments on this topic.
GridTemplateColumn Class
See Also  Members  
Telerik.WebControls Namespace : GridTemplateColumn Class


Displays each item in the column in accordance with a specified templates (item, edit item, header and footer templates). This allows you to provide custom controls in the column.

Object Model




 

Namespace: Telerik.WebControls
Assembly: RadGrid (in RadGrid.dll)

Syntax

Visual Basic (Declaration) 
Public Class GridTemplateColumn 
   Inherits GridEditableColumn
   Implements IGridEditableColumn 
Visual Basic (Usage)Copy Code
Dim instance As GridTemplateColumn
C# 
public class GridTemplateColumn : GridEditableColumn, IGridEditableColumn  

Example

            <rad:GridTemplateColumn UniqueName="TemplateColumn" SortExpression="CompanyName">
<FooterTemplate>
<img src="Img/image.gif" alt="" style="vertical-align: middle" />
Template footer
</FooterTemplate>
<HeaderTemplate>
<table id="Table1" cellspacing="0" cellpadding="0" width="300" border="1">
<tr>
<td colspan="2" align="center">
<b>Contact details</b></td>
</tr>
<tr>
<td style="width: 50%" align="center">
<asp:LinkButton CssClass="Button" Width="140" ID="btnContName" Text="Contact name"
ToolTip="Sort by ContactName" CommandName='Sort' CommandArgument='ContactName'
runat="server" /></td>
<td style="width: 50%" align="center">
<asp:LinkButton CssClass="Button" Width="140" ID="btnContTitle" Text="Contact title"
ToolTip="Sort by ContactTitle" CommandName='Sort' CommandArgument='ContactTitle'
runat="server" /></td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding="1" cellspacing="1" class="customTable">
<tr>
<td style="width: 50%">
<%# Eval("ContactName") %>
</td>
<td style="width: 50%">
<%# Eval("ContactTitle") %>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<a href='<%# "http://www.google.com/search?hl=en&q=" + DataBinder.Eval(Container.DataItem, "ContactName") + "&btnG=Google+Search"%>'>
<em>Search Google for
<%# Eval("ContactName") %>
</em></a>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<img src="Img/image.gif" alt="" />
</td>
</tr>
</table>
</ItemTemplate>
</rad:GridTemplateColumn>

Remarks

You can view and set templates using the Edit Templates command in grid's Smart Tag.

You can also create the template columns programmatically and bind the controls in the code-behind (see Programmatic creation of Telerik RadGrid).

Note: Unlike other grid columns, GridTemplateColumn cannot be set as read-only.

Inheritance Hierarchy

System.Object
   Telerik.WebControls.GridColumn
      Telerik.WebControls.GridEditableColumn
         Telerik.WebControls.GridTemplateColumn

Requirements

Namespace: Telerik.WebControls

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: RadGrid (in RadGrid.dll)

See Also