Reopen item in edit mode after insert

3 posts, 0 answers
  1. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 27 Aug 2008 Link to this post

    I have a user control as the edit form in a grid. After entering some initial information in the edit form the information needs to be saved to return  some key fields/DataItems which are then used to populate other sections/controls on the edit form for entering the remaining data.

    Rather than making the initial insert and then having to find the record in the grid reopen it, and fill out the remaining data I am trying to reopen it in edit mode automatically after saving it using "PerformInsert" in the RadGrid1_ItemCommand.

    Is This possible?

    Thanks,

    Dave

    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)

    {

    switch (e.CommandName)

    {

    case "PerformInsert":

    // Code to save to database

    // How to reopen record in edit mode

    break;

    }

    }

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

    Posted 28 Aug 2008 Link to this post

    Hello Dave,

    Try out the following code snippet to retain the InsertForm.
    cs:
     protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == "PerformInsert") 
            { 
                e.Canceled = true
            } 
        } 

    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 28 Aug 2008 Link to this post

    Princy,

    Thanks for the response.

    Using e.Canceled does keep the form open. I have onclick event on the insert button which when clicked hides the Insert Button and Shows the Update button which works fine and the intial insert into the database is also successful.

    But when the Update button is used I get an "Index was out of range - Must be a non-negitive number and less than the size of the collection" error.

    It seems to me I need to rebind the grid and somehow set the user control edit form to the new record that was created on the insert to allow me to update it.

    Thanks,
    Dave

Back to Top