views:

118

answers:

0

Hello,

I'm using Sharepoint 2010 Object Model. I'm trying to retrive the content of a Custom List. Everything works fine except if when I try to retrieve a Choice Field.

When I try to retrieve the choice field, I got an PropertyOrFieldNotInitializedException exception...

Here is the code I'm using:

            ClientContext clientContext = new ClientContext("https://mysite");
            clientContext.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo("aaa", bbb");
            clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;

            List list = clientContext.Web.Lists.GetByTitle("mylist");
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View/>";

            ListItemCollection listItems = list.GetItems(camlQuery);
            clientContext.Load(listItems);
            clientContext.ExecuteQuery();

            foreach (ListItem listItem in listItems)
            {

                listBoxControl1.Items.Add(listItem["Assigned_x0020_Company"]);

            }

Thank you for you help!

Eric