More in this section

Forums / General Discussions / Set Column to readonly when in edit mode

Set Column to readonly when in edit mode

2 posts, 0 answered
  1. Aret
    Aret avatar
    8 posts
    Registered:
    10 Oct 2011
    11 Oct 2011
    Link to this post
    I am using 'GridTemplateColumns' on my radgrid and I have trouble setting one of my columns to 'readonly' ONLY when its in 'edit mode'.  Does anyone have any suggestions in how to do this programmatically...?
  2. Maria Ilieva
    Maria Ilieva avatar
    1 posts
    Registered:
    07 Oct 2016
    14 Oct 2011
    Link to this post
    Hi Aret,

    Try the following approach:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
      
    {
      
        if (e.Item.IsInEditMode && !(e.Item is IGridInsertItem))
      
            (e.Item as GridEditableItem)["ColumnName"].Enabled = false;
      
    }


    I hope this helps.

    Best wishes,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
2 posts, 0 answered