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

Forums / Developing with Sitefinity / Problem with editing content item

Problem with editing content item

8 posts, 0 answered
  1. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    23 Dec 2009
    Link to this post

    Hi!

    I have some problem with editing generic content item: I'm trying to change it with my control(basic form with some fields) and after that save it. I'm using method for editing from documentation:

    http://www.sitefinity.com/help/developer-manual/content-items-update.html

    But my content doesn't change after I save it. Why does it happen? What can cause this?

    Thank you.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Dec 2009
    Link to this post
    Hello Paul,

    I debugged the code below and there were not any problems
    • - the first item from the GenericContent list was updated - its metadata was correctly changed.

    var contentManager = new ContentManager();
    IList listOfContentItems = contentManager.GetContent();
    if (listOfContentItems.Count > 0)
    {
        IContent firstContent = contentManager.GetContent(((IContent)listOfContentItems[0]).ID);
        firstContent.SetMetaData("Name", "Changed Name");
        contentManager.SaveContent(firstContent, ContentStatus.Published);
        Response.Write(firstContent.GetMetaData("Name") + "<br />");
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    23 Dec 2009
    Link to this post

    Hi Ivan!

    I am using this code and it doesn't work for me. 

    Maybe I should check out my content item before update? 

    I load to my form current meta data values and change them but it doesn't work.

    Thank you.

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Dec 2009
    Link to this post
    Hi Paul,

    Can you give a try to the attached control? We are not able to reproduce the problem locally using 3.7 SP2.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    23 Dec 2009
    Link to this post

    Hi Ivan!

    I have tried your control and it doesn't help. But I have some theory about my problem: on first time when I add my control on deployed site it works perfectly but after I have changed something in code of this control it became non-working.

    Can you explain how I should work with custom controls?

    Thank you.

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Dec 2009
    Link to this post
    Hello Paul,

    I think the key here is in the change you made. Can you send a sample project that the exact control - without any modifications to it does not work for you?

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    24 Dec 2009
    Link to this post

    Hi Ivan!

    Thanks for help! I understand the problem. I load data of content item to my form fields in Page_Load event but this is incorrect. After I placed my code to Page_PreRender all became cool. =)

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Dec 2009
    Link to this post
    Hello Paul,

    I am glad to hear that everything is working now. Let me know if there are any other problems with the api or any implementation.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
8 posts, 0 answered