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

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

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.

相关文章
相关标签/搜索