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

Multi row edit

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
STEPHEN
Top achievements
Rank 1
STEPHEN asked on 03 Sep 2010, 08:13 PM
I am trying to follow the info at http://www.telerik.com/help/aspnet-ajax/grdperformingbatchupdates.html regarding batch edit updates.

Can someone explain this line to me:
SqlDataSource1.UpdateCommand = String.Format("Update Customers SET ContactName='{0}' WHERE CustomerID='{1}'", newValues("ContactName"), 

Specifically the {0} and the {1}.  My grid has 2 datakeys DataKeyNames="ContributionMasterID,EmployeeID" . I am assuming that we are updating the contactname column where the customerID is equal to either a datakey or a column. If someone can explain this I can try and implement it in my scenario.

I am just starting out so please forgive my ignorance. Thank you. 

  

1 Answer, 1 is accepted

Sort by
0
STEPHEN
Top achievements
Rank 1
answered on 05 Sep 2010, 03:32 PM
Ok, I think that I figured it out. Basically the routine populates the changed values to a hash table with 2 columns. The {0} is one column and the {1} is the other. From there it takes the values and updates the underlying tables.

I changed my table so I only had one key referencing the row. Since I have mutliple fields that I am updating, do I need to set a separate update statement for each column?  Here is how I did it for 2 of the columns, it works, just not sure if it is efficient.

SqlDataSource1.UpdateCommand = String.Format("Update tblContributionsTEMP SET Deferral='{0}' WHERE ContributionTEMPID='{1}'", newValues("Deferral"), editedItem.GetDataKeyValue("ContributionTEMPID").ToString())

SqlDataSource1.Update()

SqlDataSource1.UpdateCommand = String.Format("Update tblContributionsTEMP SET Roth='{0}' WHERE ContributionTEMPID='{1}'", newValues("Roth"), editedItem.GetDataKeyValue("ContributionTEMPID").ToString())

SqlDataSource1.Update()


Tags
Grid
Asked by
STEPHEN
Top achievements
Rank 1
Answers by
STEPHEN
Top achievements
Rank 1
Share this question
or