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

ReadOnly Boundcolumn

1 Answer 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 1
Tina asked on 13 Apr 2012, 07:41 AM
Is that possible to make a boundcolumn readonly in edit mode and user should be able to insert new record to that field?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Apr 2012, 08:29 AM
Hi Tina,

Try the following code snippet to make a GridBoundColumn readonly in edit mode.

C#:
protected void radgrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem) //item is about to be inserted 
        {
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
            TextBox txt = (TextBox)insertItem["UniqueName"].Controls[0];
            txt.ReadOnly = false;
        }
        if (!(e.Item is GridEditFormInsertItem) && e.Item.IsInEditMode)   //item is about to be edit
        {
            GridEditFormItem editItem = (GridEditFormItem)e.Item;
            TextBox txt = (TextBox)editItem["UniqueName"].Controls[0];
            txt.ReadOnly = true;
        }
    }

Thanks,
Princy.
Tags
General Discussions
Asked by
Tina
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or