c# - 仅来自 Sharepoint 列表的自定义字段

标签 c# sharepoint splist

是否可以遍历共享点列表的字段集合并仅检索我们的自定义字段而不是共享点内置字段。

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

如有任何帮助,我们将不胜感激。

谢谢

最佳答案

你有两个选择:

  1. 检查字段是否为内置字段:SPBuiltInFieldId.Contains(field.Id)
  2. 查看 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/

上一篇:c# - 并行扩展

下一篇:c# - 快速生成 Excel

相关文章:

c# - 查询交错数组中所有列中的第一个元素

Sharepoint 列表转 PDF 报告

SharePoint 域和内容查询 Web 部件

sharepoint - 如何以编程方式从共享点站点获取所有文档库的列表

c# - 忽略空值 - 序列化

c# - 重写 C# 的绘制方法

c# - 为什么这个 C# 正则表达式不起作用?

sharepoint - SP2013 SharePoint 托管的应用程序模式对话框错误 : Cannot read 'hiddenButtonValueBeforeDialog'

javascript - 如何根据几个已知值确定 Sharepoint ListItem 是否存在?