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

SharePoint Item Level Permission Buttons Issue

1 Answer 47 Views
Sharepoint Integration
This is a migrated thread and some comments may be shown as answers.
Abhijit
Top achievements
Rank 1
Abhijit asked on 14 Mar 2012, 01:28 PM

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

Regards,

Abhijit Narvekar

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 16 Mar 2012, 12:39 PM
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.
Tags
Sharepoint Integration
Asked by
Abhijit
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or