i’m trying to create a silverlight wepart to get the listItems from a SharePointList.
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
MessageBox.Show(ListName);
clientContext = ClientContext.Current;
oWebsite = clientContext.Web;
List myList = clientContext.Web.Lists.GetByTitle(ListName);
CamlQuery query = CamlQuery.CreateAllItemsQuery();
ListItemCollection listItems = myList.GetItems(query);
clientContext.Load(listItems);
clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed);
}
private void onQuerySucceeded(object sender, ClientRequestSucceededEventArgs args)
{
UpdateUIMethod updateUI = DisplayInfo;
this.Dispatcher.BeginInvoke(updateUI);
}
private void DisplayInfo()
{
foreach (ListItem listItem in listItems)
{
label1.Content += listItem.FieldValues["Typ"].ToString();
}
}
Its loading the list but somehow its not loading the listItems and values…
does anyone know how to get the values of the listItems for a specific field.
Thanks in advance
Ebru
thank you for you fast response!
I did it in this way :
In Silverlight you can only access fieldValues of listItems with internal fieldNames! look here