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

Batch editing problem in Update

3 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Keshav
Top achievements
Rank 1
Keshav asked on 07 Nov 2014, 05:00 AM
Hi All ,

I am using batch editing in radgrid. Its working fine for delete and insert but when I try to update it takes the previous values of the respective cells.
Can anyone please help me find out what exactly I am missing.

FYI : I am exactly replicating batch editing demo from below link
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

Thanks & Regards ,
Anurag

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 11 Nov 2014, 01:35 PM
Hello Anurag,

It would be hard to determine exactly why the issue is observed. However, if it is observed only when updating values it may be because the UpdateParameters are not configured properly.

In case you are still experiencing issues, please provide your full markup with the related code-behind. This way we would have better understanding of your setup. It will enable us to examine the code and look for what may be causing the problematic behavior.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Keshav
Top achievements
Rank 1
answered on 12 Nov 2014, 01:53 PM
Hi Viktor,

Actually while updating it was always taking the old values of the respective cells  and hence update was not happening.
I have handled it by adding a condition to RadGrid's ItemCommand event.

if (e.CommandName.Equals("Update"))
            SqlDataSource1.OldValuesParameterFormatString = "old_{0}";

Now it works fine. But still you have some better work around , it would always be appreciated.

Also I have another doubt. When we update/delete/Insert multiple rows and then save all the changes. How can we control success/failure messages that are displayed.
Eg : If we delete 3 rows. Still the message will show as 'Row with ID=xyz is deleted'. Instead it should show something as 'Rows are deleted'.
I hope you are able to visualise my issue.


Thank you ,
 Anurag
0
Viktor Tachev
Telerik team
answered on 17 Nov 2014, 12:30 PM
Hi Anurag,

Note that when you are using Batch Editing you can access the new values and the old values via the command argument.

protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
    Hashtable newValues = (e.CommandArgument as GridBatchEditingEventArgument).NewValues;
    Hashtable oldValues = (e.CommandArgument as GridBatchEditingEventArgument).OldValues;
}

Check out the Batch Editing article where the approach is illustrated.

Regarding your second query. Note that the ItemCommand, UpdateCommand, InsertCommand events are executed for every record that is modified. If you would like to notify the user that items were updated you could use the BatchEditCommand event. This event is executed only once after the Save Changes button is clicked.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Keshav
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Keshav
Top achievements
Rank 1
Share this question
or