是否可以循环访问共享点列表的字段集合并仅检索我们的自定义字段而不是共享点内置字段。
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.
}
}
}
任何帮助,将不胜感激。
Thanks
您有两个选择:
- 检查该字段是否是内置字段:
SPBuiltInFieldId.Contains(field.Id)
- 检查SPField.SourceId http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.sourceid.aspx(来自 MSDN):
获取定义内置字段的命名空间,或者如果是自定义字段,则获取标识列表或创建该字段的网站的 GUID。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)