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

[Solved] disable column

1 Answer 399 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prathibarani
Top achievements
Rank 1
Prathibarani asked on 09 Apr 2013, 09:26 PM
Hi,

I need to loop thru radgrid columns and if they allow update, I need to make it as read only. My grid has mixed type of columns with bound columns and Template columns with Textboxes. All the columns in grid are readonly except Template columns. We allow user to enter data into textboxes. Under certain logic, I need to make entire grid as read only.  This check needs to be done out of Radgrid events.
something like this:
foreach (GridColumn gc in RadGrid1.Columns)
{
        if (gc.AllowUpdate == true)
             gc.AllowUpdate = false;

             gc.cell.style = "disablecell";
}
Please let me know how to do it.

T

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Apr 2013, 03:37 AM
Hi Prathibarani,

I'm not quite sure about your requirement. I guess you need to make the GridTemplatecolumns in the Radgrid ReadOnly. Please take a look into the following code snippet.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    foreach (GridColumn col in RadGrid1.MasterTableView.Columns)
    {
        if(your condition)
        {
            if (col.ColumnType == "GridTemplateColumn")
            {
                // Setting the ReadOnly Property
                GridTemplateColumn tempCol = (GridTemplateColumn)col;
                tempCol.ReadOnly = true;
            }
        }
    }
}

Please elaborate the scenario id it doesn't help.

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