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

Why is IBindableControl.ExtractValues called on entry into edit?

7 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
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?


7 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 13 Oct 2011, 07:35 AM
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
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.
0
Tsvetoslav
Telerik team
answered on 20 Apr 2012, 12:55 PM
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
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 Sub
 
 
End 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 Sub
End Class
0
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 Return
0
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
Tsvetoslav
Telerik team
answered on 23 Apr 2012, 03:02 PM
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
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.
Tags
Grid
Asked by
TechSavvySam
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
TechSavvySam
Top achievements
Rank 1
Share this question
or