I have a problem by creating a list item programmatically. The szenario:
2 Lists (Changes-CustomDocSet Lib, Risks-Custom Task List) with custom content types and fields
The new/edit form of the Changes List includes a DataGrid witch shows the items of the Risks list
All items, i created manually in the Risk list are shown. Now I can add additional items from the new/edit form of the Changes list using the Add button. I can insert but the item is not shown in the grid.
Risk items within new form of changes list:
Why? If i look into my Risk list, I can see the inserted item, but it is not a item, it is shown as folder type.
Add new risk item:
This is my implementation to add the item:
SPListItem item = list.Items.Add();
item["ChangeReference"] = "1";
item[SPBuiltInFieldId.Title] = title.Text;
item["Title"] = title.Text;
item["Risk"] = risk.Text;
item["Probability"] = probability.Text;
item.Update();
The List Definition only has my custom content type:
<List xmlns:ows="Microsoft SharePoint" Title="Risks" FolderCreation="FALSE" Direction="$Resources:Direction;" EnableContentTypes="TRUE" Url="Lists\Risks" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<ContentTypeRef ID="0x0108009007F1B9465C48F2AE80B77CC58A4AA7" />
</ContentTypes>
...
The manually created item can be found within list.Items, the programmitcally created item are always created in list.folders, but I don't know why and how to change that? I need normal items, not folders.
Manually vs. prog items:
Any idears?
UPDATE:
I already try to set the CT, without success. I now use a standard task list without custom content type, but it always created a folder instead an item.
While debugging, everything looks fine: