readonly column dependent of another (hidden) field

2 posts, 1 answers
  1. Paul Evers
    Paul Evers avatar
    52 posts
    Member since:
    Oct 2011

    Posted 04 Mar 2013 Link to this post

    Hi,

    I want to make a column in a RadGrid readonly dependent of the value of a different field in the dataset. This field is not shown in the grid. How do I do this?

    Paul
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2013 Link to this post

    Hi,

    Please take a look into the following code snippet.

    ASPX:
    <telerik:GridBoundColumn DataField="OrderID" UniqueName="OrderID" Display="false">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="EmployeeID" UniqueName="EmployeeID">
    </telerik:GridBoundColumn>

    C#:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {      
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem Data = (GridEditFormItem)e.Item;
            string strHiddenField = Data.ParentItem["OrderID"].Text;
            if (strHiddenField == "10259")
            {
                TextBox txt = (TextBox)Data["EmployeeID"].Controls[0];
                txt.ReadOnly = true;
            }
        }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top