ReadOnly Boundcolumn

2 posts, 0 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 13 Apr 2012 Link to this post

    Is that possible to make a boundcolumn readonly in edit mode and user should be able to insert new record to that field?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Apr 2012 Link to this post

    Hi Tina,

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

    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;

Back to Top