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

RadGrid Edit Column

2 Answers 126 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Eric Klein
Top achievements
Rank 1
Eric Klein asked on 18 Sep 2009, 08:34 PM
Is there a way in the RadGrid that when you hir the edit button a column is not editable but when you hit Insert You can still enter data.

I tried making a column Read only which it does not show up when the user hits the edit button, but it is alos not showing when the user hits the insert button.  I would like one field to be locked when editing but still allow the user to enter a value when entering a brand new record.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 21 Sep 2009, 04:21 AM
Hello Eric,

Try out the following code to hide the column in Edit mode but display it in Insert mode:
c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    {       
        if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode) && (!e.Item.OwnerTableView.IsItemInserted)) 
        { 
 
            GridEditFormItem item = (GridEditFormItem)e.Item;            
            item["ColumnUniqueName"].Parent.Visible = false
          
        }  
    } 

Thanks
Princy.
0
Eric Klein
Top achievements
Rank 1
answered on 21 Sep 2009, 12:22 PM
Thanks that is perfect..
Tags
General Discussions
Asked by
Eric Klein
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Eric Klein
Top achievements
Rank 1
Share this question
or