AUTHOR: Eyup Yusein
DATE POSTED: November 16, 2017
DESCRIPTION The AutoGenerateColumns of the grid are enabled by default. To modify their settings or implement some custom logic in the code-behind, you can use the OnColumnCreated event handler: Customizing auto-generated columns Using the e.Column.UniqueName property within this handler causes the grid to generate and assign this name explicitly. The internal auto-column generation logic afterwards may append 1 at the end of the column name since it finds an already existing column with the same name. This may lead to the following error: Cannot find a cell bound to column name "MyColumnName".
SOLUTION
To avoid this, instead of accessing the UniqueName of the auto-generated column, you can use its DataField property.
protected
void
RadGrid1_ColumnCreated(
object
sender, GridColumnCreatedEventArgs e)
{
IGridDataColumn column = e.Column
as
IGridDataColumn;
if
(column !=
null
) {
string
currColumnField = column.GetActiveDataField();
//instead of using e.Column.UniqueName
//as this usually be the same for autogenerated columns
}
Resources Buy Try