SharePoint List’s Person or Group field value as c# SPUser objet(developmenttricks.blogspot.com)

submitted by muraligollamuraligolla(74) 1 year, 7 months ago

Casting the list's Person or Group field value into SPUser object. # using(SPSite spSite = new SPSite("site URL")) # { # using(SPWeb spWeb = spSite.OpenWeb()) # { # SPList spList = spWeb.Lists["List Name"]; # SPListItem spListItem = spList.GetItemByID(itemID); # string currentValue = spListItem["Person or Group field name"].ToString(); # SPFieldUser userField = (SPFieldUser)spWeb.Lists["List Name"].Fields.GetField("Person or Group field name"); # SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(currentValue); # SPUser user = fieldValue.User; # # OR # # SPFieldUserValue spFieldUserValue = new SPFieldUserValue(web , Convert.ToString(projectItem["Person or Group field name"])); # SPUser user = spFieldUserValue.User; # } # }

add a comment |category: |Views: 103

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story