我想获取或检索特定列的数据类型 该列表在sharepoint列表中创建。
Can you help me for doing the task?
答案 0 :(得分:1)
请参阅SPField.Type(或SPField.TypeDisplayName)。
SPList list = web.Lists["my list"];
SPField field = list.Fields["particular"];
SPFieldType fieldType = field.Type;
string fieldTypeName = field.TypeDisplayName;
答案 1 :(得分:0)
建立Rich Bennema's answer(引用Microsoft.SharePoint.Client和Microsoft.SharePoint.Client.RunTime版本16 libriaries并使用Microsoft.SharePoint.Client名称空间):
using (ClientContext cont = new ClientContext(SharePointUrl))
{
cont.Credentials = new SharePointOnlineCredentials(Username, SecurePassword);
FieldCollection fields = cont.Web.Lists.GetByTitle(SharePointListName).Fields;
cont.Load(fields);
cont.ExecuteQuery();
var results =
fields.Select(
f => new
{
f.InternalName,
f.TypeDisplayName,
TextMaxLength = (f is FieldText) ? ((FieldText)f).MaxLength : 0,
FieldChoices = (f is FieldChoice) ? ((FieldChoice)f).Choices : new string[0]
}
);
}