I am getting error
Group cannot be found when I use following code:
string group = GetGroupName("1"); SPUser user = web.SiteGroups[group].Users.GetByID(SPContext.Current.Web.CurrentUser.ID);
But strangely following code works fine:
string group = "Marketing"; SPUser user = web.SiteGroups[group].Users.GetByID(SPContext.Current.Web.CurrentUser.ID);
GetGroupName is a static method that returns a string "Marketing". I don't know why it is not working in case1 but works in case2. I have checked hundred of times that the string returned by function is "Marketing" without any space or any other extra character.
Any idea why this is happening?