SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Where can I find the id of my list created in Visual Studios. I've created a list with "add new item"-> list. But now I need to have the ID of that list. I can't find it anywhere. What should I do?

share|improve this question
up vote 8 down vote accepted

You can find list template ID in Visual studio by looking at Schema.xml but you won't going to find list ID.

To get list ID you can use this code in VS,

localhost.Lists ls = new WebApplication3.localhost.Lists(); 
ls.Credentials = new System.Net.NetworkCredential("sunil", "password"); 
ls.Url = "http://mossserver/_vti_bin/Lists.asmx"; 
var lsturl = ls.GetList("Tasks"); XmlNode node = ls.GetListAndView("Tasks", ""); 
string sListID = node.ChildNodes[0].Attributes["Name"].Value; 
string sViewID = node.ChildNodes[1].Attributes["Name"].Value; 

Or you can try this simple code,

using(SPSite site = new SPSite("URL to List"))
using(SPWeb web = site.openweb())
    SPList list = web.Lists["List Name"];
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.