How to merge columns using Telerik RadGrid control

smorhaim picture smorhaim · Oct 25, 2010 · Viewed 9.9k times · Source

I know I need to use Template Columns, but I am not clearly understanding how to use it.

I have a datasource which returns a collection, I can assign each property in the collection to a column.

But how do I:

  • Merge two columns? such as col.prop1 +' '+ col.prop2 ?
  • Execute some methods on the properties such as col.prop1.ToString(overloaded)

A simple codebehind example will help. All I can find are very complex controls and stuff for examples..

Thank you.

Answer

bodee picture bodee · Nov 18, 2010

You can also use calculated columns

<telerik:GridCalculatedColumn HeaderText="Test" UniqueName="Test" DataType="System.String"
     DataFields="Field1, Field2" Expression='{0} + " - " + {1}'></telerik:GridCalculatedColumn>

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/calculatedcolumns/defaultcs.aspx