Intersoft WebGrid Documentation
Templated Cell
See Also Send comments on this topic.
Intersoft WebGrid > WebGrid Features Overview > Layouting > Templated Cell

Glossary Item Box

Another interesting new feature in WebGrid 5.0 is its ability to add ASP.NET server controls to the WebGridCell using the new Template Column Type. When using the Template Column Type, you can put any server side controls inside the CellTemplate property of the WebGridColumn.

This capability brings you greater flexibility and control over the data visualization and manipulation that suitable to your application needs. Given the current trend and ability of AJAX in delivering changes from server side control without page postback, this new feature enables developers to achieve broader scenario using professional server-side programming.
You can use Eval or Bind method for declarative data binding in the child controls of the CellTemplate.
For instance,
Code Copy Code
<ISWebGrid:WebGridColumn Caption="ContactName" ColumnType="Template" DataMember="ContactName"
    Name="ContactName" Width="200px">
    <celltemplate> 
           <asp:Label ID="Label1" runat="server" Text='<%# Bind("ContactName") %>' ForeColor="Red" Font-Italic="true" /> 
    </celltemplate>
</ISWebGrid:WebGridColumn>

 

In order to allow grouping, sorting, and editing on Templated Column, the DataMember of the WebGridColumn need to be specified. This enables WebGrid to use native value of represented row item for the data operation purpose.

Editing is not affected with Templated Column. This means you can still specify the EditType of the Column, while it is displayed using Template ColumnType.
To edit the templated cell in Visual Studio 2005 design-time, the template editing options will automatically appear when it detected Templated ColumnType in the WebGrid. The template editing can be performed by right clicking on the WebGrid instance, then point to Edit Template menu, and finally click on Columns menu item.
Once you have entered template editing mode, you can drag and drop server side controls from your toolbox into the provided region surface. You can then customize the properties of the server controls or wire events to perform logic handing.
The following screenshot shows the template editing mode in Visual Studio 2005.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.