仅来自Sharepoint列表的自定义字段 [英] Custom Fields Only From Sharepoint List

查看:100
本文介绍了仅来自Sharepoint列表的自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to loop through field collection of a sharepoint list and retrieve only our custom fields and not the sharepoint built-in fields.

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):
  1. Check if the field is a built-in field: SPBuiltInFieldId.Contains(field.Id)
  2. Check on the SPField.SourceId (from MSDN):

获取定义内置字段的名称空间,或者,如果定义的是自定义字段,则获取标识列表或网站创建位置的GUID.

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.

这篇关于仅来自Sharepoint列表的自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆