+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Renaming a IContent programatically (in a Document Library)

Renaming a IContent programatically (in a Document Library)

3 posts, 1 answered
  1. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    26 Jul 2010
    Link to this post
    Hi,

    I am trying to rename a library item, but there's something weird going on:

    I'm doing this:
    var mgr = new LibraryManager();
    IContent dbContent = mgr.GetContent(item.ID);
    dbContent.SetMetaData("Name", item.Name);

    and all following calls to dbContent.GetMetaData("Name") return the new name. However, the change doesn't appear to be persisted in the database at all: at the following request, the document's name is back to the old name.

    Am I missing something (a way to commit my changes?) ?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Jul 2010
    Link to this post
    Hello Lucas,

    You should call SaveContent method - Manager.SaveContent(IContent item)

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    26 Jul 2010
    Link to this post
    Hi Ivan,

    Timely response as usual! I didn't expect the LibraryManager to be able to do transactions and expected SetMetaData to save the data as soon as it was called.

    I feel extra stupid now ;-(
Register for webinar
3 posts, 1 answered