This is a migrated thread and some comments may be shown as answers.

Reopen item in edit mode after insert

2 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Miller
Top achievements
Rank 2
Dave Miller asked on 27 Aug 2008, 10:56 PM
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 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Aug 2008, 12:19 PM
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.
0
Dave Miller
Top achievements
Rank 2
answered on 28 Aug 2008, 04:14 PM
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

Tags
Grid
Asked by
Dave Miller
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Dave Miller
Top achievements
Rank 2
Share this question
or