I have a RadGrid that puts all rows in to editmode when the page loads, as outlined in the documentation using the PreRender event. I have also configured an UpdateAll item command to enable updating all records at once, as outlined in "Performing Batch Updates". The problem is that it updates all records even if no change was made. Is there someway to mark a row as dirty and only run the update query if it has changed?
Any suggestions on how I can limit the update to only fire if a change to the row was made?
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand |
If e.CommandName = "UpdateAll" Then |
For Each editedItem As GridEditableItem In RadGrid1.EditItems |
Dim newValues As Hashtable = New Hashtable |
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem) |
sdsSODetails.UpdateCommand = String.Format("UPDATE rx_srorder_extend SET STOP_NO='{0}', PLAN_REC_DATE='{1}', CONF_REC_DATE='{2}', CONF_NO='{3}', CONF_BY='{4}', CHANGED_BY='{6}' WHERE SRORDER_ID='{7}' IF @@ROWCOUNT = 0 INSERT INTO rx_srorder_extend (SRORDER_ID, PLAN_REC_DATE, CONF_REC_DATE, CONF_NO, CONF_BY, STOP_NO, CHANGED_BY) VALUES ('{7}', '{1}','{2}','{3}','{4}','{0}','{6}')", newValues("STOP_NO"), newValues("PLAN_REC_DATE"), newValues("CONF_REC_DATE"), newValues("CONF_NO"), newValues("CONF_BY"), newValues("SCHED_STATUS_ID"), newValues("CHANGED_BY"), editedItem.GetDataKeyValue("SRORDER_ID").ToString()) |
sdsSODetails.Update() |
Next |
End If |
End Sub |
Private Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender |
If Not IsPostBack Then |
For Each item As GridItem In RadGrid1.MasterTableView.Items |
If TypeOf item Is GridEditableItem Then |
Dim editableItem As GridEditableItem = CType(item, GridDataItem) |
editableItem.Edit = True |
End If |
Next |
RadGrid1.Rebind() |
End If |
End Sub |