SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can somebody please suggest me to set/change the view programatically in xsltlistviewwebpart from AllItems to something else, based on logged in user. Requirement is to find out the logged in user and based on that load the listviewwebpart with some view pertaining to that user.

Thanks for the help!!

share|improve this question

To do this programmatically you need to change the ListViewWebPart.ViewGuid property. There is sample code in the second part of this msdn blog post.

Before you start coding, have you considered using audiences? This will allow you to show different filtered lists or hide/show web parts based on the identity of the user or groups of users.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.