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

Hide column when edit forum displays

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 29 Mar 2010, 10:24 PM
foreach (GridColumn col in radGdSurvey.MasterTableView.Columns)  
            {  
                  
                if (col.ColumnType == "GridBoundColumn" && col.UniqueName == "JobsID")  
                {  
                    if (e.CommandName == RadGrid.EditCommandName)  
                    {  
                        (col as GridBoundColumn).ReadOnly = true;  
                        col.Visible = false;  
                    }  
                    else  
                    {  
                        (col as GridBoundColumn).ReadOnly = false;  
                        col.Visible = true;  
                    }  
                }  
            }       

Ok I hit my edit button on the grid, when it pops i want to make JobsID readonly in the edit form, the above does not work, I am do something wrong I just do not know what.  Any help would be great.

Thx in advance

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Mar 2010, 06:06 AM
Hi Gary,

To make JobsID readonly in the edit form you can try the following code inside ItemCommand event.
Here is the code I tried:

C#:
 
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)   
{   
   GridBoundColumn boundColumn = (GridBoundColumn)RadGrid1.MasterTableView.GetColumnSafe("JobsID");   
   if (e.CommandName == RadGrid.EditCommandName)   
   {   
     boundColumn.ReadOnly = true;   
   }   
   else   
   {   
     boundColumn.ReadOnly = false;   
   }   
}  

Thanks,
Princy.
Tags
Grid
Asked by
Gary
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or