How to combine columns using Telerik RadGrid control

I know that I need to use template columns, but I don’t understand how to use it.

I have a data source that returns a collection, I can assign each property in the collection to a column.

But like me:

  • Merge two columns? for example col.prop1 +' '+ col.prop2?
  • Follow some methods for 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.

+5
source share
3 answers

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

+3

, , , "display".

public string Prop1 { get; set; }
public string Prop2 { get; set; }

public string PropertiesFormatted
{
  get
  {
    return this.Prop1 + " - " + this.Prop2;
  }
}

. , , , . , .

- . MSDN, Telerik, - :

<telerik:GridTemplateColumn UniqueName="TemplateColumn">
  <ItemTemplate>
    <span><%# DataBinder.Eval(Container.DataItem, "Prop1") %> - <%# DataBinder.Eval(Container.DataItem, "Prop2") %></span>
  </ItemTemplate>
</telerik:GridTemplateColumn>

URL-, Grid: http://www.telerik.com/help/aspnet-ajax/grdcustomizewithgridtemplatecolumn.html

+1

, , - , .

0
source

All Articles