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'm creating an SPList item programatically. Everything goes fine, I add a list, I add spfields to it.

SPList list = (SPList)oWeb.Lists[listName];

SPField libraryNameField = new SPField(list.Fields, "Library", Names.LIBRARY_NAME);
libraryNameField.Type = SPFieldType.Text;
libraryNameField.Required = true;

But I encounter a problem. The fields are created, but not viewed on default view. What am I missing? How can I achieve that programatically?

share|improve this question
up vote 1 down vote accepted

You need to specifically add the column to the list view. For example,

//Get list object
SPList list = oWeb.Lists[listName];
//Get the view 
SPView defaultView = list.DefaultView;
//Add the desired fields
//Update the view
//Update the List -- Not entirely sure this step is necessary.
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.