Reputation: 127
I need to update some of the values of the item being edited in my code-behind based on some values in a custom Edit Form on our Rad Grid. Can I access the item (and update some values) from one of the Grid's event handlers? Currently I'm storing the values in temporary variables and then injecting the new values in the ObjectDataSource's Inserting/Updating event handlers, but it would be much nicer if I could do it all in one spot. (I can't do it all in the ObjectDataSource event handlers as I can't access the controls inside my Grid's Edit Form.)
I've been playing with the ExtractValues and UpdateValues methods of the GridEditableItem object, but I'm not having any luck.
Any tips would be greatly appreciated :)
Upvotes: 0
Views: 4388
Reputation: 1442
Kind of a late answer but hopefully it will help someone:
In the web page code behind do this:
Partial Public Class SomeWebPage
Implements IBindableControl
Public Sub ExtractValues(ByVal dictionary As IOrderedDictionary) Implements IBindableControl.ExtractValues
' Your code to get the custom value
Dim CustomString As String = "the custom thing"
dictionary.Add("DatabaseItemName", CustomString)
End Sub
The "DatabaseItemName" is the data item name expected in the database code. I always use ObjectDataSource to access the database because we mostly use stored procedures for our database CRUD operations. If you do this, the items shows up automatically in the DB code. Hopefully using this info, you can dig around on the Internet and find more detailed examples.
BTW, I am using this with Telerik RadGrid and this code is actually added to the ASCX user control that defines the grid edit form.
Upvotes: 0
Reputation: 11
Try using the grid's UpdateCommand event handler. The event argument object that's coming into it contains a reference to the editform item. From there you can extract the newly-entered values and pass them to the ObjectDataSource:
Hashtable newValues = new Hashtable(); ((GridEditableItem)e.Item).ExtractValues(newValues);
//now the newValues hash table contain key/value pairs for each column field.
Hope it helps.
Upvotes: 1