Step: 1 Add the SharePoint Reference
Refer this article
Step: 2 Add the SharePoint namespace
Refer this article
Step: 2 Add the SharePoint namespace
Update the Share Point Listusing Microsoft.SharePoint.Client;
Create List Tablepublic string UpdateTaskList(string Url, string UserName, string Password, string Title, string Describtion, string ListID){try{ClientContext context = new ClientContext(Url);context.Credentials = new NetworkCredential(UserName, Password);Web site = context.Web;Guid id = new Guid(ListID.ToString());context.Load(web);List objList = web.Lists.GetById(id);objList.Title = Title;objList.Description = Describtion;objList.Update();context.ExecuteQuery();return "";}catch (Exception e){return e.Message;}}
Retrieving SharePoint Listvoid CreateListtable()
{try{dtList = new DataTable();dtList.Columns.Add("List", typeof(string));dtList.Columns.Add("Description", typeof(string));dtList.Columns.Add("ListType", typeof(string));dtList.Columns.Add("ItemCount", typeof(string));dtList.Columns.Add("LastModified", typeof(string));dtList.Columns.Add("ID", typeof(string));}catch (Exception){throw;}}
public DataTable GetTaskList(string Url, string UserName, string Password){try{CreateListtable();ClientContext context = new ClientContext(Url);context.Credentials = new NetworkCredential(UserName, Password);Web site = context.Web; ;ListCollection listcollection = web.Lists;context.Load(listcollection);context.ExecuteQuery();foreach (List listName in listcollection){//Only Task listif (listName.BaseTemplate == 107){DataRow dr = dtList.NewRow();dr["List"] = listName.Title;dr["Description"] = listName.Description;dr["ListType"] = listName.BaseTemplate;dr["ItemCount"] = listName.ItemCount;dr["LastModified"] = listName.LastItemModifiedDate;dr["ID"] = listName.Id;dtList.Rows.Add(dr);}}return dtList;}catch (Exception){return null;}
No comments:
Post a Comment