Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
640
ObjectDataSource and grid events
posted

I have been playing around with the sample on this KB:

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9968

However, in addition to the binding, what I'm looking to do is handle the events of a user changing a value in the grid within my object(s).

Example:
In the solution on the page above  (HOWTO:Bind a custom object to a WebGrid using declarative programming with the ObjectDataSource),  you are binding the people collection object to the grid so that each row represents a Person object's properties.

I may want to validate the 'Age' property of the person object to prevent someone from entering in an invalid number. I changed the person class to this:
 Public Property Age() As Integer
        Get
            Return _age
        End Get
        Set(ByVal value As Integer)
            If value > 100 Then
                Throw New ArgumentException("Too Old!")
            End If
            _age = value
        End Set
    End Property

but the ArgumentException does not get thrown when I changed the value in the grid.

Am I approaching this the wrong way? I want to have all the logic in my object classes and keep the interactions with the grid strictly on an update/formatting basis, but this won't work if I cannot get the grid to keep the objects updated.

Thanks!