gpt4 book ai didi

c# - 如何通过 C# 在 SharePoint 2007 列表中获取仅包含用户创建字段的列表?

转载 作者:行者123 更新时间:2023-11-30 17:14:46 25 4
gpt4 key购买 nike

您好,感谢您的关注!

背景

我目前有一个 C# 方法,用于遍历 SharePoint 列表集合并返回这些 SP 列表的列表,包括它们的列/SPFields 的嵌套列表。

问题

如何通过 C# 在 SharePoint 2007 列表中获取仅由用户创建的字段的列表?

到目前为止的代码。 . .

SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPListCollection lists = web.Lists;

var PellaListCollection = new List<PellaListModel>();

foreach (SPList l in lists) {
var PellaList = new PellaListModel();
var PellaListColumns = new List<PellaListColumn>();
foreach (SPField c in l.Fields) {
if (c.Hidden.Equals(false))
{
var type = c.FieldTypeDefinition.TypeName.ToString();
var col = new PellaListColumn
{
ColumnId = c.Id,
ColumnDataType = type,
ColumnTitle = c.Title
};
PellaListColumns.Add(col);
}
}
PellaList.ListColumns = PellaListColumns;
PellaList.ListId = l.ID;
PellaList.ListTitle = l.Title;
PellaList.Description = l.Description;
PellaListCollection.Add(PellaList);
}

web.AllowUnsafeUpdates = false;

return PellaListCollection;
}

如您所见,现在我正在过滤哪些 SPFields 不是“隐藏的”,但这仍然会返回相当多的标准 SharePoint 生成的字段和列表。我只需要用户创建的字段。

谢谢!

马特

最佳答案

您正在寻找 FromBaseType SPField 的属性。如果该字段是列表的原始架构的一部分,则此属性为真。

看看这个好SharePoint Exchange article了解更多。

关于c# - 如何通过 C# 在 SharePoint 2007 列表中获取仅包含用户创建字段的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8436954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com