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

Batch edit update from code behind

1 Answer 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alyssa
Top achievements
Rank 1
Alyssa asked on 25 Nov 2013, 10:09 AM
Hi,
How to do batch edit update from code behind and not through allowautomaticupdates.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Nov 2013, 10:15 AM
Hi Alyssa,

You can use the OnBatchEditCommand event of the radgrid to obtain the required scenario. Using the GridBatchEditingCommandType we can identify the events. Please try the following code snippet.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnBatchEditCommand="RadGrid1_BatchEditCommand">
 <MasterTableView EditMode="Batch" CommandItemDisplay="Top" DataKeyNames="ID">
    <BatchEditingSettings OpenEditingEvent="Click" />

C#:
protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
{
    foreach (GridBatchEditingCommand command in e.Commands)
    {
        if ((command.Type == GridBatchEditingCommandType.Update))
        {
            Hashtable newValues = command.NewValues;
            Hashtable oldValues = command.OldValues;
            string ID = newValues["ID"].ToString();
            string Name = newValues["Name"].ToString();        
           
            try
            {
               //Code to Update
            }
            catch (Exception ex)
            {
              // Exception Message
            }
        }
    }
}

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