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

New Item After Insert

1 Answer 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 03 Dec 2013, 09:34 PM
I have an interesting scenario:

I have an editable rad-grid with a SQL back-end.  I would like, after a new row is inserted, to "Add a new record," open in edit mode (not inserted yet), with some information from the previous entry.  Is this at all possible?

Some sort of User prompt for the type of the subsequent entry would be handy as well.

Thanks,
Mark

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Dec 2013, 03:55 AM
Hi Mark,

I guess you want to open the currently inserted record in edit mode. Please try the following code snippet.

C#:
 bool isItemInserted = false;
 static  string value=string.Empty;
 bool isCancel = false;
 
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
  isItemInserted = true;
}
 
protected void RadGrid1_PreRender(object sender, EventArgs e)
{     
    if((value != null)&&(!isCancel))
    {
        foreach (GridDataItem item in RadGrid1.Items)
        {
            string val = item["ID"].Text;
            if (string.Compare(val, value) == 0)//Comparing the value to identify currently inserted item
            {
                item.Edit = true;
                isItemInserted = false;
                RadGrid1.Rebind();
            }
        }
    }     
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if ((e.CommandName == RadGrid.CancelCommandName)||(e.CommandName==RadGrid.UpdateCommandName))
    {
        isCancel = true;
    }
}
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
      //Code to Update
    }
}

Thanks,
Princy
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or