2
  1. 我想获取或检索在共享点列表中创建列表的特定列的数据类型。

    Can you help me for doing the task?
    
4

2 回答 2

2

请参阅SPField.Type(或SPField.TypeDisplayName)。

SPList list = web.Lists["my list"];
SPField field = list.Fields["particular"];
SPFieldType fieldType = field.Type;
string fieldTypeName = field.TypeDisplayName;
于 2013-01-21T17:46:06.057 回答
0

基于Rich Bennema 的回答(引用 Microsoft.SharePoint.Client 和 Microsoft.SharePoint.Client.RunTime 版本 16 库并使用 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]
                }
            );
}
于 2015-02-24T21:56:29.127 回答