SharePoint Item Level Permission Buttons Issue

2 posts, 0 answers
  1. Abhijit
    Abhijit avatar
    10 posts
    Member since:
    Jun 2011

    Posted 14 Mar 2012 Link to this post

    Hi Everyone,

    I am trying to implement item level security in my application and i have run into an issue wherein i wish to hide a few of the controls in my grid view. Below are the complete details of my scenario,

    I have list named as States which contains the following data

    1. Washington - Item Permissions assigned - Adam has Write permissions
    2. New York - Item Permissions assigned - Charles has Read permissions
    3. Texas - No Permissions assigned to both the users

    According the SharePoint object model when i try to fetch all the records, i get the data as per my requirement i.e. Adam is only able to view Washington and Charles is only able to view New York.

    Now this data is shown in the gridview which has view,edit buttons against it.

    i wish to trim these buttons according to the permissions of the user on the list items. Kindly let me know if there is a way to do it.

    I was curious to know whether anyone has knowledge of what does SPSecurityTrimmedControl.PermissionContext property do? Does it apply security triming based on the current list item permission, if so how does it do it. please provide a sample


    Abhijit Narvekar
  2. Tsvetoslav
    Tsvetoslav avatar
    1823 posts

    Posted 16 Mar 2012 Link to this post

    Hello Abhijit,

    In order to hide the grid buttons, attach an event handler to the ItemDataBound event, check the user permissions, check the column values as well (all information is contained in ((GridDataItem)e.Item).DataItem), then get hold of the edit button through the FindControl method and button ID "EditButton" and hide it:

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridDataItem)
            ImageButton button = ((GridDataItem)e.Item).FindControl("EditButton") as ImageButton;
            //check the permissions and hide the button if necessary
            //button.Visible = false;

    Hope it helps.

    All the best, Tsvetoslav
    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.

Back to Top