UpdateCommand doesn't clear the edit controls

6 posts, 0 answers
  1. Dave Hayward
    Dave Hayward avatar
    40 posts
    Member since:
    Jul 2012

    Posted 18 Jan 2010 Link to this post

    There are a lot of posts on the UpdateCommand function, but I couldn't find a solution to my problem in any of them.

    I'm hooking into UpdateCommand and performing my own data update functions. Using the examples and suggestions from the site I was able to get everything working beautifully, with one exception. After performing the actual update, the grid remains in what appeard to be the edit mode. (This behaves the same if I don't hook into UpdateCommand and there is no data source defined).

    I looked for solutions to this, and there seem to be a couple suggested that work well if the EditMode is EditForms, but I'm using InPlace. When I try to use the solutions from the other posts, I get an exception: Only items with IsInEditMode set to true can be updated. This happens if I try to call MasterTableView.ClearEditItems() or if I try to set e.Item.Edit to false

    I looked at the samples in the Help section, and none of them show any hint there's something more to be done, so I'm not sure what I'm doing wrong. Can anyone suggest a way to get back to 'normal' selection mode with no editing controls visible?

    TIA.  
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Jan 2010 Link to this post

    Hello Dave,

    Have you set the AllowAutomaticUpdates property of the grid to true? If so, try setting it to false and see if it helps close the edit form after update.

    Also the following code should be tried in UpdateCommand, to clear the rows in editmode
    cs:
     protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
        {  
            // update query code goes here  
      
            RadGrid1.MasterTableView.ClearEditItems(); 
        }  

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave Hayward
    Dave Hayward avatar
    40 posts
    Member since:
    Jul 2012

    Posted 19 Jan 2010 Link to this post

    Princy,

    Thanks for your prompt response. I had tried that one, as I found it in one of your earlier posts. That's the one that cased the exception. I also tried:

    e.Item.Edit = false
     That too gave me the same exception.

    If I use EditForms mode it works, but in InPlace EditMode, it fails.

  5. Dave Hayward
    Dave Hayward avatar
    40 posts
    Member since:
    Jul 2012

    Posted 19 Jan 2010 Link to this post

    I don't know if it helps at all, but I'm experiencing this behaviour with the DropDown column type. I also have a HTMLEditor column, and it doesn't behave like this. After returning from the UpdateCommand handler, the grid returns to its nomal (non-editing) mode.

    I don't know if this helps.
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Jan 2010 Link to this post

    Hi Dave,

    Could you try firing the FireCommandEvent for the Cancel event in the UpdateCommand after the update query as shown below:

    GridEditableItem editedItem=(GridEditableItem)e.Item;
    editedItem.FireCommandEvent("Cancel""");


    Do let me know if this works for your scenario.

    Thanks,
    Princy
  7. Dave Hayward
    Dave Hayward avatar
    40 posts
    Member since:
    Jul 2012

    Posted 20 Jan 2010 Link to this post

    Princy,

    Thanks! That worked. It seems like a bit of a hack though. Is UpdateCommand supposed to work like this? Should I report a bug?Maybe I just don't grasp the concepts yet.

    Anyway, that works, and that's great.

    Thanks again.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017