Why is IBindableControl.ExtractValues called on entry into edit?

8 posts, 0 answers
  1. TechSavvySam
    TechSavvySam avatar
    38 posts
    Member since:
    Jul 2009

    Posted 11 Oct 2011 Link to this post

    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?


  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 13 Oct 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. TechSavvySam
    TechSavvySam avatar
    38 posts
    Member since:
    Jul 2009

    Posted 19 Apr 2012 Link to this post

    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.
  5. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 20 Apr 2012 Link to this post

    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.
  6. TechSavvySam
    TechSavvySam avatar
    38 posts
    Member since:
    Jul 2009

    Posted 20 Apr 2012 Link to this post

    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
  7. TechSavvySam
    TechSavvySam avatar
    38 posts
    Member since:
    Jul 2009

    Posted 20 Apr 2012 Link to this post

    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
  8. TechSavvySam
    TechSavvySam avatar
    38 posts
    Member since:
    Jul 2009

    Posted 20 Apr 2012 Link to this post

    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. :(


  9. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 23 Apr 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017