How can we filter a list (while loading) by comparing it with a filter value that exists on the server side in Sharepoint 2010. i.e for example


I know that we can implement this with QueryStringFilter webpart, but it is not secure as anyone can change the employeeId value in the URL.

We can get the employeeId on the server side from logged in user, but we don't know how to filter the view only for his Id. Is there a way to intercept the List load to set this filter ?


You can make use of the new SharePoint 2010 rest services (listdata.svc) to filter your list data inside your code.

More here: http://msdn.microsoft.com/en-us/library/ff798339.aspx

  • Where should we put the code to filter the list. Should we write some kind of usercontrol/aspx page & refer it in the master page ? Could you point me to an example. Thanks vivek
    – user1967
    Dec 14 '10 at 16:37
  • Well depending upon your requirements, you can write a user control and register it using a delegate control. Or you can write a web part.
    – Vivek
    Dec 15 '10 at 5:48

If the employeeid is stored in a user profile property, you could use a "Current User Filter"


It works in a similar way to the QueryStringFilter, being you add it to the page that the list in on.

Then you configure the web part properties, setting the "Value to provide" to be employeeid

Then connect the filter to the list view, providing the value to the employeeid on the list.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy