Question

I have created a SharePoint list. I have a situation to change the list name using c#.

please suggest any idea.

Était-ce utile?

La solution

using (var oSite = new SPSite(fundURL))
{
      using (var oWeb = oSite.OpenWeb())
      {
          var listWithArticles = oWeb.Lists.TryGetList("Articles");

          if(listWithArticles != null)
          {
             listWithArticles.Title = "Exhibits";
             listWithArticles.Update();
          }
      }
}

Autres conseils

You can try with Csom Code Below for changing the list name

ClientContext context=new ClientContext(SiteUrl);
List requiredlist=context.Web.Lists.GetByTitle("required list name");
context.Load(requiredlist);
context.ExecuteQuery();

requiredlist.Title="The New Name for the List";
requiredlist.Update();
context.ExecuteQuery();

if you want to change the Url of the List, use the below snippet

        ClientContext context=new ClientContext(SiteUrl);
        List list = context.Web.Lists.GetByTitle("List name");
        context.Load(context.Web);
        context.ExecuteQuery();
        context.Load(list.RootFolder);
        context.ExecuteQuery();
        list.RootFolder.MoveTo(context.Web.ServerRelativeUrl+"required Url");
        list.Update();
        context.ExecuteQuery();
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top