Set GridBoundColumn to readonly when in edit mode?

4 posts, 0 answers
  1. Jack
    Jack avatar
    12 posts
    Member since:
    Sep 2007

    Posted 22 Dec 2009 Link to this post

    Using InPlace mode, Can someone tell me if it is possible to set the ReadOnly property to true for a GridBoundColumn at runtime when the user select Edit? My scenario is to not allow a user to change a key field value in edit mode but be able to provide that value in insert mode. So.. the first column of the grid is the primary key value which needs to be supplied on insert but cannot be changed on edit.

    If it is possible, can you direct me down the right path?

    Thanks

    Jack Huddleston

  2. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 22 Dec 2009 Link to this post

    Hello Jack,

    Please try the following approach and let me know whether it is suitable for you:
    protected void gvSpex_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item.IsInEditMode && !(e.Item is IGridInsertItem))
            (e.Item as GridEditableItem)["ColumnName"].Enabled = false;
    }

    Best regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chad
    Chad avatar
    19 posts
    Member since:
    Aug 2008

    Posted 22 Jan 2010 Link to this post

    This seems like a pretty standard business rule. Would it be possible to include some sort of boolean attribute (e.g. InsertOnly="true") for grid columns?

    Controls like the FormView provide an Insert mode and an Edit mode because the two are noteably different from time to time. A similar RadGrid mechanism for "InsertItemTemplate" and "EditItemTemplate" would also prove useful. I realise it could be manipulated through code, but minimizing code-behind is always nice.
  5. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 26 Jan 2010 Link to this post

    Hello Chad,

    Thank you for your suggestions. I will pass them to our development team for future consideration.

    Best regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top