Hide edit column based on condition

2 posts, 0 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 13 Apr 2012 Link to this post

    Here is the code that I am trying. How to hide autogenerated edit column based on cell text?
    protected void StoresGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                TableCell cell = (TableCell)item["StoreId"];
               if(cell.Text=="1")
          //how to hide autogenerated edit column here
                  
    }
    }

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Apr 2012 Link to this post

    Hi Tina,

    Try the following code to hide AutoGenerateEditColumn based on text in the cell.

    C#:
    if (cell.Text == "1")
       {
           LinkButton btn = (LinkButton)item["AutoGeneratedEditColumn"].Controls[0];
           btn.Visible = false;
       }

    Thanks,
    Princy.
Back to Top