I have a list of list item ids and I was trying to get SPListItemCollection ?
var siteId = SPContext.Current.Site.ID;
var webId = SPContext.Current.Web.ID;
var listId = Request.QueryString["listId"];
var itemIds = Request.QueryString["IDs"].Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var listItems = new List<SPListItem>();
using (var site = new SPSite(siteId))
{
using (var web = site.OpenWeb(webId))
{
var spList = web.Lists[new Guid(listId)];
foreach (var itemId in itemIds)
{
SPListItem spListItem = spList.GetItemById(Convert.ToInt32(itemId));
listItems.Add(spListItem);
}
}
}
How can I get SPListItemCollection from listItems list or is there any other better to approach to get the same?