get list items in sharepoint 2010 c# using client object model:
get list items in sharepoint 2010 c# using client object model:
Insert the following Namespace:
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
Use the following code.
ListItemCollection _icoll;
public MainPage()
{
InitializeComponent();
ClientContext ccsite = new ClientContext(ApplicationContext.Current.Url);
ccsite.Load(ccsite.Web);
List listobj = ccsite.Web.Lists.GetByTitle("ListName");
ccsite.Load(listobj);
CamlQuery qry = new CamlQuery();
qry.ViewXml = "<View/>";
_icoll = listobj.GetItems(qry);
ccsite.Load(_icoll);
ccsite.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(success), null);
}
private void success(object sender,ClientRequestSucceededEventArgs arg)
{
Dispatcher.BeginInvoke(datacon);
}
private void datacon()
{
foreach (ListItem item in _icoll)
{ comboBox1.Items.Add(Convert.ToString(item["ColumnName"])); }
}
Comments
Post a Comment