New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

ColumnCreated Event

This event is fired after the creation of auto-generated columns (including structure columns). You can get the column from the event arguments and check its data type or unique name to recognize it. In this event you could set the column properties and customize the look and behavior of the column.

Event Parameters

  • (object) sender

    • The control that fires the event
  • (GridColumnCreatedEventArgs) e

    • Event arguments

      • (GridColumn) e.Column

        Gets the column that have been created.

      • (GridTableView) e.OwnerTableView

        Gets the GridTableView which holds the column which have been created.

Attaching the event

In the Markup

ASP.NET
<telerik:RadGrid ID="RadGrid1" runat="server" OnColumnCreated="RadGrid1_ColumnCreated">
</telerik:RadGrid>

In the Code behind

C#
protected void Page_Init(object sender, EventArgs e)
{
    RadGrid1.ColumnCreated += RadGrid1_ColumnCreated;
}

The event handler

C#
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
    GridColumn column = e.Column;
    GridTableView ownerTableView = e.OwnerTableView;
}

Examples

Customizing auto-generated columns

C#
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
    if (e.Column.UniqueName == "FirstName")
    {
        e.Column.HeaderText = "Name";
        e.Column.AutoPostBackOnFilter = true;
    }
}

Localizing the Grid Headers

ASP.NET
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" DataSourceID="SqlDataSource1" AllowSorting="True" runat="server" OnColumnCreated="RadGrid1_ColumnCreated">
  <MasterTableView Width="100%" AutoGenerateColumns="True" />
</telerik:RadGrid>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT * FROM [Customers]"> </asp:SqlDataSource>

See Also