views:

286

answers:

1

Hi, I want to do this but without accesing the list "items", that is to say, to access the column perhaps with the root site or a contenttype, not depending on a list that can be created or not inside the Sharepoint app.

SPFieldChoice choice = (SPFieldChoice)items.Fields[namefield];

                foreach (string choiceName in choice.Choices)
                {
                  //etc...
                }
+2  A: 

You can use web.Fields or ContentTypes[typeName].Fields:

SPWeb web = ... ;

SPFieldChoice choice = (SPFieldChoice)web.Fields[namefield];

or

SPFieldChoice choice = (SPFieldChoice)web.ContentTypes[typeName].Fields[namefield];
Voyta