Sharepoint的UpdateList方法:新创建的列是不可见 [英] Sharepoint UpdateList Method : Newly created Columns are not visible
问题描述
我的工作的代码。它成功地工作。我面临
,而问题是:
I worked on code .It is working successfully. But Problem i am facing is:
新列不在列表中可见(我试着与设置必需=TRUE)
New Columns are not visible in List ( I tried with With Setting Required = "TRUE" ).
我试着用compairing可见光和不可见光列字段的值。
差,我发现是:可视列(手动创建)不包含版本值。
wereas列我创建拥有它。
I tried with compairing Field Value of Both Visible and No-Visible Columns. Difference i found is : Visible Columns (Created Manually) doesn't contain Version value. wereas columns i am creating have it.
所以我试图用传球空值ndVersion.Value。
So i tried with passing null value to "ndVersion.Value".
但它仍然没有工作和automaticaly把一些价值版本。
But it is still not working and automaticaly putting some value to version.
您能帮助我在这?
我试图解决给定这里
但din't再次合作。 (
But it din't Worked again. :(
推荐答案
其实有几件事情,当你添加一列在浏览器列表,发生:
There are actually several things that happen when you add a column to a list in the browser:
- 字段添加到列表
- 字段添加到列表内容类型
- 字段添加到默认视图
当您使用代码添加一列,你可能只修改名单,但没有内容类型(定义新/编辑表单)或视图(定义列表视图)
When you add a column using code, you may only be modifying the list, but not the content type (which defines new/edit forms) or the view (which defines list views)
var field = list.Fields[fieldName];
var ctype = list.ContentTypes[contentTypeId];
var fieldref = new SPFieldLink(field);
ctype.FieldLinks.Add(fieldref);
ctype.Update();
var view = list.Views[viewName];
view.ViewFields.Add(field);
view.Update();
这篇关于Sharepoint的UpdateList方法:新创建的列是不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!