是否可以遍历共享点列表的字段集合并仅检索我们的自定义字段而不是共享点内置字段。
using (SPSite site = new SPSite("http://localhost/"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["My List"];
foreach (SPField field in list.Fields)
{
//We also get sharepoint built-in column here. And we don't want that, just our
//custom created fields.
}
}
}
如有任何帮助,我们将不胜感激。
谢谢
最佳答案
你有两个选择:
- 检查字段是否为内置字段:
SPBuiltInFieldId.Contains(field.Id)
- 查看 SPField.SourceId (来自 MSDN):
Gets either the namespace that defines a built-in field or, if it a custom field, the GUID that identifies the list or Web site where it was created.
关于c# - 仅来自 Sharepoint 列表的自定义字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5340746/