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

[Solved] RadGrid Columns Edit Mode by Condition

2 Answers 266 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcio Nascimento
Top achievements
Rank 1
Marcio Nascimento asked on 28 Sep 2009, 06:17 PM
Hi There,

I have a radgrid with four columns. However, I have a condition: if type "A" I must show all the four columns enabled for editing. If type "B" I must show only three columns for editing.

The problem is that if I hide the column or use readonly property the field appear for editing anyway.

Is there a way or a functionality of RadGrid that could make possible to hide programmatically those fields for editing?

Thanks for any help.

Marcio Nascimento

2 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 28 Sep 2009, 07:49 PM
You could try this in the code-behind:

  
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)   
{   
     if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))   
     {  
        //if condition B then: 
        GridEditFormItem myColumn = (GridEditFormItem)e.Item;   
        myColumn["columnName"].Parent.Visible=false
        else 
        { 
            //do nothing 
        } 
     } 

I do find it strange that setting ReadOnly = true did not hide the field when you edited - a column should be invisible in the edit view when it is read only


0
Marcio Nascimento
Top achievements
Rank 1
answered on 15 Oct 2009, 02:58 PM
Hi Schlurk,

Thanks for the code. It's working now.
And you are right about the readonly property.

Regards,

Marcio Nascimento
Tags
Grid
Asked by
Marcio Nascimento
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Marcio Nascimento
Top achievements
Rank 1
Share this question
or