以编程方式创建的列表项始终是一个文件夹 [英] Programmatically created list item is always a folder

查看:75
本文介绍了以编程方式创建的列表项始终是一个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我通过编程方式创建列表项时遇到问题. szenario:

I have a problem by creating a list item programmatically. The szenario:

-2个具有自定义内容类型和字段的列表(Changes-CustomDocSet库,Risks-Custom任务列表)

- 2 Lists (Changes-CustomDocSet Lib, Risks-Custom Task List) with custom content types and fields

-更改列表的新/编辑表单包括一个DataGrid,其中显示了风险"列表中的项目

- 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.

为什么?如果我查看风险"列表,则可以看到插入的项目,但它不是项目,而是显示为文件夹类型.

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.

这是我添加项目的实现:

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> ...

    </ContentTypes> ...

手动创建的项可以在list.Items中找到,程序创建的项始终在list.folders中创建,但是我不知道为什么以及如何更改它?我需要普通物品,而不是文件夹.

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.

有想法的人吗?


推荐答案

风险列表"的内容类型"的详细设置是什么?

What is the detailed setting of Content Type for the Risk List ?

我已经测试过的C#代码段,它将在任务列表中创建一个项目.请尝试删除自定义内容类型,然后再试一次以查看创建的项目是否可以使用.

The C# code snippet I have tested, it will create a item in the task list. Please try to remove the custom Content Type and then try again to see if the item created will work. 

还要尝试将EnableFolderCreation属性设置为false并测试问题是否仍然存在:

And also try to set EnableFolderCreation properties to false and test if the issue still existed:


谢谢

最好的问候


这篇关于以编程方式创建的列表项始终是一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆