Client object Model Using Silverlight in SharePoint (Getting Records From SharePoint List)


ClientContext context = new ClientContext(ApplicationContext.Current.Url);  
  context.Load(context.Web);
  List Projects = context.Web.Lists.GetByTitle("Opportunity Financial Data");
  context.Load(Projects);           
  CamlQuery query = new Microsoft.SharePoint.Client.CamlQuery();

  string startDateFx = FirstDate.ToString("yyyy-MM-dd");
  string endDatFx = LastDate.ToString("yyyy-MM-dd");

  camlQueryXml = "<View><Query><Where><And><Geq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>" + startDateFx + "</Value></Geq><Leq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>" + endDatFx + "</Value></Leq></And></Where></Query></View>";

  query.ViewXml = camlQueryXml;
  _financialData = Projects.GetItems(query);
  context.Load(_financialData);

 context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null);


///

private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
 {        
     Dispatcher.BeginInvoke(BindData);
 }

//The BindData method will refer the Items which are going to bind to GridView

//Note : To bind the data to gridview use the "_financialData" collection


Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell