I have built a Web Part in Visual Studio 2008 to show the current user's information (this is for WSS 3.0).

I have no problem iterating through all the fields in the SPListItem, but I want to filter out the fields that are NOT shown on the User Information page (_layouts/userdisp.aspx). I can't seem to identify the property to compare to. When I filter by Hidden = false, I still get SIP Address, Content Type, etc.

An explanation: When a user views their information from the user information list in one site collection, they see Account, Name, E-Mail, Job Title, About Me, etc. In a different site collection, we have added Department, Code and Branch. I want to create a Web Part that shows the visible fields, so I can deploy it across all site collections without customizing. One option is to make these fields required, and then filter by Required = true, but these are not necessarily required fields and I would have to edit every site collection for it to work.

Any suggestions on what property or properties to use? I used the WSS-3.0 tag for this question, as I think the answer would be different in SharePoint Foundation.

  • The solution I found also applies to getting the correct ViewFields for any list, it seems SPView.ViewFields does NOT reflect the fields that are defined in the browser, I am not sure why. The workaround is to define the local SPWeb object as such: SPWeb objWeb = SPContext.Current.Site.OpenWeb(SPContext.Current.Web.ServerRelativeUrl).
    – CigarDoug
    May 9, 2013 at 13:33

1 Answer 1


It seems that sharepoint gets this fields from one of the list view for user information list (Detail View I guess, I can't verify it exactly, because I always redirected to my host site). But you can check it:

var list = web.Lists["User Information List"];
var view = list.Views["Detail View"];
for (int i = 0; i < view.ViewFields.Count; i++)
     var fieldInternalName = view.ViewFields[i];
  • Thanks, Kai! That sent me in the right direction, but here's a quirky thing: The viewfields are for the unedited detail view, the workaround I found was to replace web (the current web site, or SPContext.Current.Web) with this: SPContext.Current.Site.OpenWeb(SPContext.Current.Web.ServerRelativeUrl) Then it works as designed. I have to retrieve the SPField using the ViewField, but it works somewhat, almost, elegantly. Thanks again for the revelation.
    – CigarDoug
    Dec 29, 2011 at 18:39
  • This does meet my immediate need, which is to provide the site manager with a means of managing the fields shown in the web part without inventing a complicated method (like in the properties pane). However, the Details View does NOT match the userdisp.aspx form. If anyone has a solution to the original problem, I would like to hear it.
    – CigarDoug
    Dec 30, 2011 at 11:14
  • Try to check other views for user information list. Dec 30, 2011 at 11:44

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.