Copied to clipboard

Flag this post as spam?

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


  • Robin Hansen 135 posts 368 karma points
    Aug 20, 2013 @ 22:34
    Robin Hansen
    0

    Cannot bind repeater after node deleted

    I display certain noden in a repeater in a Usercontrol - it all works as intenteed, execpt fot the delete button (deleteCommand) - the repeater simply will not refresh! - what am I doing wrong...? (The item is deleted from the repeater when I refresh the browser (f5) though)

    I use Umbraco v 4.11.10, asp.net 4.0, MySQl Db

    My codebehind looks af folloes:

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDishes();
            }
        }
    
        protected void LoadDishes() 
        {
            string memberID = Convert.ToString(Member.CurrentMemberId());
            IEnumerable<Node> nodes = uQuery.GetNodesByType("Dish").Where(x => x.GetProperty("dishCreator").ToString().Equals(Convert.ToString(memberID))).OrderByDescending(r => r.CreateDate);
    
            Repeater1.DataSource = nodes;
            Repeater1.DataBind();
        }
    
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            HiddenField HFValue = (HiddenField)e.Item.FindControl("HiddenFieldId");
            int dishId = Convert.ToInt32(HFValue.Value);
            Document d = new Document(dishId);
            User user = User.GetUser(1);
            if (Convert.ToString(e.CommandArgument) == "visibleCommand")
            {
                d.getProperty("umbracoNaviHide").Value = 1;
                d.Publish(user);
            }
            else if (Convert.ToString(e.CommandArgument) == "invisibleCommand")
            {
                d.getProperty("umbracoNaviHide").Value = 0;
                d.Publish(user);
            }
            else if (Convert.ToString(e.CommandArgument) == "deleteCommand")
            {
                d.delete();
            }
            umbraco.library.UpdateDocumentCache(d.Id);
            umbraco.library.RefreshContent();
            LoadDishes();
        }
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 21, 2013 @ 11:20
    Dave Woestenborghs
    0

    You need to unpublish your document first:

    d.UnPublish();
                    d
    .delete();
                   
  • Robin Hansen 135 posts 368 karma points
    Aug 21, 2013 @ 16:53
    Robin Hansen
    0

    The Nodes DO gets deleted - the problem is that the Repeater does'nt update itself (databind)- so I have to reload the browser (f5) to see it deleted... :-|

    -when I run visibleCommand or invisibleCommand the page/repeater updates(databinds) itself nicely, but NOT when I delete a node...

    I think the code makes a lot of sence, or do I miss something here...?!?

Please Sign in or register to post replies

Write your reply to:

Draft