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

I am trying to load a drop down list with the same items that a lookup field uses. I thought it would be relatively straightforward, but the line

SPList lookupList = lookupWeb.Lists[lookupField.LookupList];

Throws an exception despite the list with that ID existing in the SPWeb. (I checked both through the object model and SharePoint Manager)

        SPFieldLookup lookupField = targetLibrary.Fields["DocumentType"] as SPFieldLookup;
        using (SPWeb lookupWeb = SPContext.Current.Site.OpenWeb(lookupField.LookupWebId))
            SPList lookupList = lookupWeb.Lists[lookupField.LookupList];
            foreach (SPListItem item in lookupList.Items)
                ddlDocumentType.Items.Add(new ListItem(item["Title"].ToString(), item["ID"].ToString()));

List '{843fa16d-ec85-45c3-8d27-20d0241d41d6}' does not exist at site with URL

Is there something simple I am missing?

share|improve this question
up vote 1 down vote accepted

Highest voted answer doesn't even provide the right answer. Try doing this:

SPList lookupList = lookupWeb.Lists[new Guid(lookupField.LookupList)];

Instead of this:

SPList lookupList = lookupWeb.Lists[lookupField.LookupList];
share|improve this answer

So SPFieldLookup has an actual Guid for LookupWebId property and only a string for the LookupList property. So the line

SPList lookupList = lookupWeb.Lists[lookupField.LookupList];

Is using the string override which looks up the list name.

So the learning here, yet again, is do not expect the SharePoint object model to be consistent in any way.

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.