This is a migrated thread and some comments may be shown as answers.

Set GridBoundColumn to readonly when in edit mode?

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 22 Dec 2009, 04:25 PM
Using InPlace mode, Can someone tell me if it is possible to set the ReadOnly property to true for a GridBoundColumn at runtime when the user select Edit? My scenario is to not allow a user to change a key field value in edit mode but be able to provide that value in insert mode. So.. the first column of the grid is the primary key value which needs to be supplied on insert but cannot be changed on edit.

If it is possible, can you direct me down the right path?

Thanks

Jack Huddleston

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 22 Dec 2009, 09:43 PM
Hello Jack,

Please try the following approach and let me know whether it is suitable for you:
protected void gvSpex_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item.IsInEditMode && !(e.Item is IGridInsertItem))
        (e.Item as GridEditableItem)["ColumnName"].Enabled = false;
}

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chad
Top achievements
Rank 1
answered on 22 Jan 2010, 04:09 PM
This seems like a pretty standard business rule. Would it be possible to include some sort of boolean attribute (e.g. InsertOnly="true") for grid columns?

Controls like the FormView provide an Insert mode and an Edit mode because the two are noteably different from time to time. A similar RadGrid mechanism for "InsertItemTemplate" and "EditItemTemplate" would also prove useful. I realise it could be manipulated through code, but minimizing code-behind is always nice.
0
Daniel
Telerik team
answered on 26 Jan 2010, 03:42 PM
Hello Chad,

Thank you for your suggestions. I will pass them to our development team for future consideration.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Jack
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Chad
Top achievements
Rank 1
Share this question
or