Get list using its id

I am trying to retrieve a list using its ID, however it does not work, and I cannot understand why

It works without a problem ...

using (SPSite site = new SPSite("http://example.org/sites/specific/staffhandbook")) using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists["Documents"]; // process... } 

It should be, but is it not?

 using (SPSite site = new SPSite("http://example.org/sites/specific/staffhandbook")) using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists["29540646-bcab-4beb-8a91-648c1f3178b8"]; // process... } 
+6
c # sharepoint sharepoint-2007
source share
1 answer

SPListCollection accepts either Int32 (index), a String (list name), or Guid (identifier), so you should do this

 Guid guid = new Guid("29540646-bcab-4beb-8a91-648c1f3178b8"); SPList list = web.Lists[guid]; 
+11
source share

All Articles