开发者

How to Get query all the lists of a SharePoint site through Silverlight Client object model

I have a requirement in which I have to show the number of documents uploaded by a user in all the lists and libraries in a SharePoint site in a Silverlight webppart.

How much ever I try I keep getting the error "The property or field has not been initial开发者_Python百科ized. It has not been requested or the request has not been executed. It may need to be explicitly requested." This is my coding

  public void displayCount()
    {
        foreach (string list in lists)
        {
            web = ctx.Web;
            ctx.Load(web);
            List list = web.Lists.GetByTitle(list);
            ctx.Load(list);
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View/>";
            listItems = list.GetItems(camlQuery);
            ctx.Load(listItems);
            ctx.ExecuteQueryAsync(Success, null);
        }
    }

    private void Success(object sender, ClientRequestSucceededEventArgs args)
    {

        UpdateUIMethod updateUI = DisplayInfo;
        this.Dispatcher.BeginInvoke(updateUI);
    }

    private void DisplayInfo()
    {
        try
        {
            TextBlock tb = new TextBlock();
            tb.Text = Convert.ToString(listItems.Count);
            LayoutRoot.Children.Add(tb);
        }
        catch (Exception ex)
        {
            TextBlock tb = new TextBlock();
            tb.Text = ex.Message;
            LayoutRoot.Children.Add(tb);
        }
    }


see http://www.sharepointqanda.com/2010/10/how-to-get-listitems-count-in-all-the-lists-of-a-sharepoint-site-through-silverlight-client-object-model/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜