Find List details if you know the List IDs

if you only know the list id and want to know the other details of the list, below is the code to get that
protected void Page_Load(object sender, EventArgs e)
{
string[] _listArray = {"List ID 1", "List ID 2", "List ID 3"};
using (SPSite oSite = new SPSite("MySiteURL"))
{
SPWeb oWeb = oSite.OpenWeb();
SPListCollection allLists = oWeb.Lists;
foreach (SPList list in allLists)
{
foreach (string singleArraylist in _listArray)
{
if (list.ID.ToString().ToUpper() == singleArraylist.ToString().ToUpper())
{
Response.Write("List Name :\t" + list.Title + " List ID :" + list.ID + "");
}
}
}
}
}

No comments:

Post a Comment