Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • trfletch 598 posts 604 karma points
    Feb 18, 2011 @ 00:21
    trfletch
    0

    Custom section changing table field when clicking delete

    Hi all,

    I have an Umbraco 4.5.2 site and I am trying to setup a custom section. I have been running through the Video tutorials but I want to do something slight different than what they suggest. When right clicking on a node an selecting "Delete" rather than completely deleting the record from the table I would rather have it set a value in a status field which would mean it doesn;t display.

    I currently have a field in my table called activeStatusID and so far my custom section is only showing entries where this is set to 1, therefore I when I right click on a node an select Delete I would like it to change the value of that field to 2 which would me that it would no longer show in the list. Below is the code that I have got from the videos for deleting an entry (which I cannot get working for some reason). How would I modify this so that instead of deleting the whole row in the database it just changes the value of my activeStatusID field?

     

     

    public bool Delete()

    {

     

     

    Application.SqlHelper.ExecuteNonQuery("delete from Users where id = @id",

     

     

    Application.SqlHelper.CreateParameter("@id", ParentID));

     

     

    return true;

     

    }

    Thanks in advance for any help

  • Daniel Bardi 927 posts 2562 karma points
    Feb 18, 2011 @ 01:13
    Daniel Bardi
    0

    Just attached to the Delete event for document.

    You would then be able to cancel the event and add your own logic; in this case you could then change the value in the database

  • trfletch 598 posts 604 karma points
    Feb 18, 2011 @ 10:08
    trfletch
    0

    Hi Daniel,

    Thanks for your reply. I understand what I have got to do, I was actually looking for some help with the code to do it. From my understanding I am going to need to make a change to the code I posted above it is just that I am unsure what change I need to make. I have only just started learning asp.net so I'm still struggling with my code.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies