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

Column ReadOnly Property not accesible from code-Behind

2 Answers 600 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 04 Nov 2008, 10:54 AM
I am trying to make my popup-edit window match the columns that are displayed in my radgrid (Which is decided by the user). The only way I can see how to change weather a column is displayed in the edit window is by setting the "ReadOnly" property.

This works fine from the front end, but how do I change a column to readonly = false from the code behind?

.aspx
<telerik:GridBoundColumn DataField="Custom5" EmptyDataText="&amp;nbsp;" HeaderText="Custom5" SortExpression="Custom5" UniqueName="Custom5" Display="false" ReadOnly="true">
</telerik:GridBoundColumn>

 

.aspx.cs - I am looking to set the property back to false, but it does not exist!!
RadGrid1.Columns.FindByUniqueName(LI.Value).ReadOnly=

false;

Thanks,
Greg

 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Nov 2008, 11:32 AM
Hello Greg,

Check out the following coe to set the GridBoundColumn's ReadOnly property to false.
cs:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    {         
       foreach(GridColumn col in RadGrid1.Columns) 
          { 
            if (col.UniqueName == "Custom5" ) 
              { 
                GridBoundColumn colBound = col as GridBoundColumn; 
                colBound.ReadOnly =false
              }                   
          }    
   }   

Thanks
Princy.
0
Greg
Top achievements
Rank 1
answered on 04 Nov 2008, 11:56 AM

Works like a charm...

I edited it to not loop through the table, but rather to target a single col at a time...

 

 

GridColumn col = RadGrid1.Columns.FindByUniqueName(colName);
GridBoundColumn colBound = col as GridBoundColumn;
colBound.ReadOnly =
false;

Thanks,
Greg

 

Tags
Grid
Asked by
Greg
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Greg
Top achievements
Rank 1
Share this question
or