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

Using object model I need to add an item to a list. The list has 4 custom content types. Depending on data provided I need the item to be of a specific content type.

How is this done?

Using SPListItem oItem = list.AddItem(); does not accept a content type as a parameter. Neither can you set it later it seems the property is read only.

Any ideas?

share|improve this question
I also have the same problem... can you please help me if you found the solution for that... thanks... – user4928 Sep 28 '11 at 16:54
user4928 - if you have a simliar problem that my answer does not solve, then please create a new question and explain why my answer isn't relevant. The answer to your problem may help others! :) – James Love Sep 28 '11 at 22:06

Use SPList.Items.Add() to return the item you're adding (as an instance of SPListItem), instead of SPList.AddItem().

Then you can update the ContentTypeId using myListItem["ContentTypeId"] to set the content type.

Here's an example:

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.