List<string> myCollection = new List<string>();
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[ListName];
int i = 0;
foreach (SPListItem item in list.Items)
{
SPListItem spitem = list.Items[i];
SPFieldLookupValue group = new SPFieldLookupValue(spitem[LookupColumnName].ToString());
string lookedUpItemTitle = group.LookupValue;
myCollection.Add(lookedUpItemTitle);
i++;
}
}
}
});
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[ListName];
int i = 0;
foreach (SPListItem item in list.Items)
{
SPListItem spitem = list.Items[i];
SPFieldLookupValue group = new SPFieldLookupValue(spitem[LookupColumnName].ToString());
string lookedUpItemTitle = group.LookupValue;
myCollection.Add(lookedUpItemTitle);
i++;
}
}
}
});
No comments:
Post a Comment