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

hide GridEditCommandColumn if not an admin

1 Answer 314 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 05 Apr 2012, 07:54 PM
Hi,
Trying to find a way to hide the
 <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" EditText="Notes"></telerik:GridEditCommandColumn>
if a person doe snot have admin privledges, I see lots of examples for other buttons and controls but so far not this way.

Protected Sub myRadGrid_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles myRadGrid.ItemDataBound
        If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
            Dim EditFormcmdItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
  
            If checkAdmin() = False Then
                EditFormcmdItem.FindControl("EditCommandColumn").Visible = False
            End If
        End If
    End Sub

1 Answer, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 06 Apr 2012, 06:54 AM
Hello Kevin,

protected void Page_Load(object sender, EventArgs e)
    {
         RadGrid1.MasterTableView.GetColumn("EditCommandColumn").Display = false;
//OR
        RadGrid1.MasterTableView.Columns.FindByUniqueName("EditCommandColumn").Visible = false;
    }

OR
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            (item["EditCommandColumn"].Controls[0] as LinkButton).Style.Add("Display", "none");
        }
}



Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or