0

I am creating a Expense management application. I have a page that lists the expenses in the system (they click the expense list to view this).

I now want to change this so that it ONLY displays the logged in users expenses (i don't want user A looking at user B expenses).

I have done this using a web template in visual studio, any modification must be made using visual studio (i cant do this in SP designer as this app will be sent to many clients).

How would i go about approaching this?

1
  • this is in Sharepoint 2010 Nov 7, 2012 at 9:16

2 Answers 2

2

You can create a view using SPView class and in query give Author=[Me] and set this view as default view

About the default "All Items" view, set its permission to be viewable to only Administrators or Group with Full Control...

See How to create SPView Programmatically and Programmtically create SPView

Let me know if you need more help!

2
  • Thanks for the reply. I also came across the SPGridView object while searching google. How does this differ from SPView. In what scenarios would i use one over the other? Nov 7, 2012 at 9:33
  • SPView is similar to making views of a list through UI... However, SPGridView is a SharePoint Control to achieve same look and feel as the Default List View has - They are completely different from each other... Nov 7, 2012 at 9:40
1

As Arsalan mentioned you can create a SPView which does filter by Me. Here is the CAML query for doing that:

     query.Query = "<Where><Eq><FieldRef Name='Author' /><Value Type='Integer'><UserID Type='Integer' /></Value></Eq></Where>";

Here I have written a blog post which shows how to create a an SPView which does filter by Me: http://sharepointnadeem.blogspot.in/2012/02/create-view-to-filter-items-by-me.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.