New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
CreateColumnEditor Event
Fired -after- the NeedDataSource event of the grid (which is raised right after the PageLoad event) and -before- any postback events for controls on the page/user control.
Event Parameters
-
(object)
sender- The control that fires the event
-
(GridCreateColumnEditorEventArgs)
e-
Event arguments
-
(GridColumn)
e.ColumnGets or sets the GridEditor asociated column.
-
(IGridColumnEditor)
e.ColumnEditorGets or sets the column editor that have been created.
-
-
Attaching the event
In the Markup
ASP.NET
<telerik:RadGrid ID="RadGrid1" runat="server" OnCreateColumnEditor="RadGrid1_CreateColumnEditor">
</telerik:RadGrid>
In the Code behind
C#
protected void Page_Init(object sender, EventArgs e)
{
RadGrid1.CreateColumnEditor += RadGrid1_CreateColumnEditor;
}
The event handler
C#
protected void RadGrid1_CreateColumnEditor(object sender, GridCreateColumnEditorEventArgs e)
{
GridColumn column = e.Column;
IGridColumnEditor columnEditor = e.ColumnEditor;
}
Examples
Attaching a custom column editor programmatically
In a CreateColumnEditor event handler, you can attach an instance of your custom editor to a column by assigning the e.ColumnEditor parameter of the handler:
C#
protected void RadGrid1_CreateColumnEditor(object sender, Telerik.Web.UI.GridCreateColumnEditorEventArgs e)
{
GridBoundColumn column = e.Column as GridBoundColumn;
if (column != null && column.DataField == "ShipAddress")
{
e.ColumnEditor = new MyMultiLineTextBoxColumnEditor(column);
}
if (column != null && column.DataField == "OrderDate")
{
e.ColumnEditor = new MyDateColumnEditor(column);
}
}