Hi.
Is it possible to distinguish between edit and insert mode for a gridNumricColumn when not use a formTemplate?
I have read the documentation Distinguish edit/insert mode on ItemCreated/ItemDataBound but i still have problem to get it to work.
I want the gridNumricColumn (CardNumber) to be readonly=false when insertmode and readonly=true otherwise. The problem is that the field CardNumber is not visible when insertmode withe the following code:
Have tried both with ItemCreated and ItemDataBound methode.
Is it possible to distinguish between edit and insert mode for a gridNumricColumn when not use a formTemplate?
I have read the documentation Distinguish edit/insert mode on ItemCreated/ItemDataBound but i still have problem to get it to work.
I want the gridNumricColumn (CardNumber) to be readonly=false when insertmode and readonly=true otherwise. The problem is that the field CardNumber is not visible when insertmode withe the following code:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataInsertItem && e.Item.IsInEditMode)
{
var column = (GridNumericColumn)e.Item.OwnerTableView.GetColumnSafe("CardNumberColumn");
if (e.Item.OwnerTableView.IsItemInserted)
column.ReadOnly = false;
else
column.ReadOnly = true;
}
}
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
DataSourceID
=
"LinqDataSource1"
ondatabound
=
"RadGrid1_DataBound"
onitemcommand
=
"RadGrid1_ItemCommand"
onitemdatabound
=
"RadGrid1_ItemDataBound"
onitemcreated
=
"RadGrid1_ItemCreated"
>
<
MasterTableView
AutoGenerateColumns
=
"FalseDataKeyNames="
CardNumber,ProductNumber,MediaType"
DataSourceID
=
"LinqDataSource1"
EditMode
=
"InPlace"
>
<
Columns
>
<
telerik:GridNumericColumn
DataField
=
"CardNumber"
DataType
=
"System.Int32"
HeaderText
=
"Kortnr."
ReadOnly
=
"true"
SortExpression
=
"CardNumber"
UniqueName
=
"CardNumberColumn"
>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
DataField
=
"CardName"
HeaderText
=
"Kortnavn"
SortExpression
=
"CardName"
UniqueName
=
"CardName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
CancelText
=
"Avbryt"
EditText
=
"Endre"
InsertText
=
"Sett inn"
UpdateText
=
"Oppdater"
></
telerik:GridEditCommandColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Have tried both with ItemCreated and ItemDataBound methode.