views:

23

answers:

1

Hi All,

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 initialized. 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);
        }
    }
A: 

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/

ron
Hi I need to get the count of the list items returned by the CAML query not the count of the total list items in the lists.