In this article we will be seeing how to display the SharePoint 2010 list items in the Silverlight Datagrid using Client Object Model.Steps Involved:
Programmatically create custom role in selected sub sites in SharePoint 2010
How to create Visual web part using Sandbox solution in SharePoint 2010
after i pasted the above code, using Microsoft.SharePoint.Client; PagedCollectionView,ListItemCollection etc. are not being recognized even after adding respective dlls
Hey I followed same steps as you mentioned but when it executes below statement context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), new ClientRequestFailedEventHandler(failed)); it throws this exception."ServerVersion = 'context.ServerVersion' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'" And it doesn't go in any success and failed event handlers. What could be the issue? My code exactly look like:http://msdn.microsoft.com/en-us/library/ff728647.aspx Thanks in advance. Waiting for your response.
ApplicationContext.Current.Url it is giving null in the runtime so i hardcoded that url and gave my sharepoint site... Thanks Reena
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.SharePoint.Client; using System.Threading; using System.Windows.Data; namespace SLGetFilesFromDL { public partial class MainPage : UserControl { private ListItemCollection _empDetails; public class Project { public String empName { get; set; } } public MainPage() { InitializeComponent(); ClientContext context = new ClientContext("http://intranet.wingtip.com"); context.Load(context.Web); List empDetails = context.Web.Lists.GetByTitle("Employee List"); context.Load(empDetails); CamlQuery query = new CamlQuery(); string camlQueryXml = "<View><ViewFields>" + "<FieldRef Name=\"Title\" />" + "</ViewFields></View>"; query.ViewXml = camlQueryXml; _empDetails = empDetails.GetItems(query); context.Load(_empDetails); context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null); } private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args) { // This is not called on the UI thread. Dispatcher.BeginInvoke(BindData); } private void BindData() { List<Project> projects = new List<Project>(); foreach (ListItem li in _empDetails) { projects.Add(new Project() { empName = li["Title"].ToString(), }); } PagedCollectionView pcv = new PagedCollectionView(projects); this.dgFilesFromDL.ItemsSource = pcv; pcv.SortDescriptions.Add(new System.ComponentModel.SortDescription("empName", System.ComponentModel.ListSortDirection.Ascending)); } } } I used the above code and i am getting that error... I have title field in the sharepoint List.. Thanks Reena
Hi ravi...have u given the caml query (string camlQueryXml = "<View><ViewFields>" +"<FieldRef Name=\"Title\" />" + "</ViewFields></View>";) and list name properly...i think u didnt use the proper column name in the code..thanks...vijai