TechSavvySam
Top achievements
Rank 1
TechSavvySam
asked on 11 Oct 2011, 06:50 PM
I have a user control which implements IBindableControl and it is used as the edit form for a RadGrid.
What I don't understand is why is IBindableControl.ExtractValues being called when the user Edits or Inserts a row? Shouldn't it only be called as you are LEAVING the edit/update operation?
What I don't understand is why is IBindableControl.ExtractValues being called when the user Edits or Inserts a row? Shouldn't it only be called as you are LEAVING the edit/update operation?
7 Answers, 1 is accepted
0
Hello Sam,
RadGrid's edit form has a property called SavedOldValues - these are the initial field values that are displayed in the edit form and then modified by the user. In order to preserve those values before the user has started changing them the ExtractValues method is called and the SavedOldValues property is populated.
Hope it helps.
Regards, Tsvetoslav
the Telerik team
RadGrid's edit form has a property called SavedOldValues - these are the initial field values that are displayed in the edit form and then modified by the user. In order to preserve those values before the user has started changing them the ExtractValues method is called and the SavedOldValues property is populated.
Hope it helps.
Regards, Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
TechSavvySam
Top achievements
Rank 1
answered on 19 Apr 2012, 01:59 PM
Is there a definitive way to figure out from inside my implementation of IBindableControl.ExtractValues which call it is?
I need this because I have code in there that will only work once the edit form has been filled in and run through the validation controls. This code blows up on the first call into ExtractValues() because all of the form's fields are not set. I don't see a way to determine which call this is and I don't think that sticking a try/catch around the whole section of code is really what I want to do.
Or is there a way to disable the SavedOldValues stuff--I see no use for that in my code as I'm not using built-in data access because we use Object Data Sources for everything into stored procedures.
I need this because I have code in there that will only work once the edit form has been filled in and run through the validation controls. This code blows up on the first call into ExtractValues() because all of the form's fields are not set. I don't see a way to determine which call this is and I don't think that sticking a try/catch around the whole section of code is really what I want to do.
Or is there a way to disable the SavedOldValues stuff--I see no use for that in my code as I'm not using built-in data access because we use Object Data Sources for everything into stored procedures.
0
Hi Sam,
Could you paste your code and explain your logic so that I be able to provide you with a suitable solution to your requirement.
Regards,
Tsvetoslav
the Telerik team
Could you paste your code and explain your logic so that I be able to provide you with a suitable solution to your requirement.
Regards,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
TechSavvySam
Top achievements
Rank 1
answered on 20 Apr 2012, 02:51 PM
Partial Public Class TslBaseDataBoundUserControl Inherits System.Web.UI.UserControl Implements IBindableControl Private _dataItem As Object = Nothing Public Property DataItem() As Object Get Return Me._dataItem End Get Set(ByVal value As Object) Me._dataItem = value End Set End Property Public Overridable Sub ExtractValues(ByVal dictionary As IOrderedDictionary) Implements IBindableControl.ExtractValues ' call to proprietary code to extract data from form End SubEnd Class' This is the ASCX codebehind for the GridEdit form:Partial Public Class FieldValidationItemDetailEdit Inherits TslBaseDataBoundUserControl Implements IBindableControl Public Overrides Sub ExtractValues(ByVal dictionary As IOrderedDictionary) Implements IBindableControl.ExtractValues MyBase.ExtractValues(dictionary) ' Which call to ExtractValues is this? If the SavedOldValues call return because code below ' will blow up otherwise because it depends on controls being set certain ways and they won't ' be set that way until user enters stuff on page and page executes Validation controls. End SubEnd Class0
TechSavvySam
Top achievements
Rank 1
answered on 20 Apr 2012, 03:09 PM
I think I might have just figured out the solution. It looks like DataItem is set to Nothing only when coming back to extract the values off the page after an insert or update is initiated, so this code would work:
Public Overrides Sub ExtractValues(ByVal dictionary As IOrderedDictionary) Implements IBindableControl.ExtractValues ' Return if this is the SaveOldValues pass If DataItem IsNot Nothing Then Return0
TechSavvySam
Top achievements
Rank 1
answered on 20 Apr 2012, 03:35 PM
I spoke too soon. This doesn't work because when you hit "Cancel" it runs back through this code w/o having run the Validation routines and thus the code STILL blows up on Cancel. :(
0
Hello Sam,
What I meant is namely the validation code - please, provide it, the rest is just the skeleton implementation of the IBindableTemplate.
Regards,
Tsvetoslav
the Telerik team
What I meant is namely the validation code - please, provide it, the rest is just the skeleton implementation of the IBindableTemplate.
Regards,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.