Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Normally I create a New List if I want to add an additional column to a List that already exists in a web.

Wondering what would be the best option, should I create a new list with additional column or if there is any script or something I can use to add column to existing one.

I am using sharepoint 2007 and I have this list on hundred of pages.

Content Type

 <ContentTypes>
      <ContentTypeRef ID="0x0101">
        <Folder TargetName="Forms/Document" />
      </ContentTypeRef>
      <ContentTypeRef ID="0x0120" />
    </ContentTypes>
share|improve this question

1 Answer 1

up vote 2 down vote accepted

you can add a column to the list by doing (a number field in this example):

SPList lst = oSPWeb.Lists["List Name"];
SPFieldNumber fld= (SPFieldNumber)lst.Fields.CreateNewField(SPFieldType.Number.ToString(), "Column Name");
lst.Fields.Add(fld);
lst.Update();

However its better to create a content type, create a list and then bind the content type to the list. That way you can manage your lists and columns better than when you constantly keep creating new lists...

share|improve this answer
    
In list schema.xml I have got this, but I am not really sure what its being used for here, –  Muhammad Raja Jul 25 '12 at 10:31
    
edited my question –  Muhammad Raja Jul 25 '12 at 10:31

Your Answer

 
discard

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.