0
votes

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...
                }
1

1 Answers

2
votes

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];