Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Programatically Check if the logged in user matches with user in a list item

$
0
0

Hi All, 

I have a custom list with 1) title column 2) People column. 

I simple need to check if the logged in user = user in the column 2, and if yes fill a List<> with column 1 value. 

But when comparing, the value in list item is in different format than what we get by user.ToString() 

Following is what I tried: 

SPUser user = oWeb.CurrentUser;

List<String> usergrps = new List<String>();

foreach (SPListItem itemA in GrpSubsItems)
{
      if (itemA["SubscribedBy"].ToString() == user.ToString())
            usergrps.Add(itemA["Group"].ToString());
}


itemA["SubscribedBy"].ToString() gives = 10;#Some Name

where as user.ToString() gives = i:0#.w|domain\user 

Kindly guide if my approach is not correct. Thanks. 


Regards, Nayan


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>