1

SharePoint からリストの列に保存されている URL と URL の説明を収集しようとしていますが、URL 値を収集する方法がわかりません。

これは私のコードです:

            var queryResultSaleListItems = clientContext.LoadQuery(listData);

            clientContext.ExecuteQuery();

            //Read the Data into the Object
            var TipsList = from Tips in queryResultSaleListItems
                            select Tips;
            ObservableCollection<Tips> colTips = new ObservableCollection<Tips>();
            //Read Every List Item and Display Data into the DataGrid
            foreach (SPSClient.ListItem item in TipsList)
            {

                var tips = new Tips();
                tips.TitleTip = item.FieldValues.Values.ElementAt(1).ToString();
                tips.App = item.FieldValues.Values.ElementAt(4).ToString();
                //should collect the url 
                tips.URL = item.FieldValues.Values.ElementAt(5).ToString();
                //should collect the description of the url
                tips.URLdesc = item.FieldValues.Values.ElementAt(5).ToString();

                colTips.Add(tips);
            }
            ListboxTips.DataContext = colTips;

私の表現では >

((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Url

((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).説明

ご協力いただきありがとうございます、

4

1 に答える 1

4

でフィールドFieldUrlValueを取得するために使用します。hyperlinkClient Object Model

次のコードを使用します。

        string server = "siteURL";
        var ctx = new ClientContext(server);
        var web = ctx.Web;
        var list = web.Lists.GetByTitle("CustomList");
        var listItemCollection = list.GetItems(CamlQuery.CreateAllItemsQuery());  

        ctx.Load(listItemCollection);                      

        ctx.ExecuteQuery();

        foreach (Microsoft.SharePoint.Client.ListItem listItem in listItemCollection)
        {                
            string acturlURL =  ((FieldUrlValue)(listItem["URL"])).Url.ToString(); // get the Hyperlink field URL value
            string actdesc = ((FieldUrlValue)(listItem["URL"])).Description.ToString(); // get the Hyperlink field Description value
        }
于 2012-04-11T12:43:20.670 に答える