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?

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.