Is this correct behaviour

Is this correct behaviour

Old forum URL: forums.lhotka.net/forums/t/4513.aspx


griff posted on Tuesday, March 18, 2008

Hi

I am using a detailsview with csladatasource and ERO.
All seems okay when I update the detailsview except when I clear out a text field (using say tab - all text in field is highlighted and I press tab to clear contents).  This seems to pass Nothing as the value into the get /set -

Public Property PostCode As String
            Get
                CanReadProperty("PostCode", True)
                Return m_postCode
            End Get
            Set (ByVal value As String)
                CanWriteProperty("PostCode", True)
                If m_postCode <> value Then
                    m_postCode = value
                    PropertyHasChanged("PostCode")
                End If
            End Set
        End Property


the resultant stored proc does not update the database field.  Is this standard behaviour? and if so what's the best way to deal with this.

Thanks
Richard

RockfordLhotka replied on Wednesday, March 19, 2008

That is normal ASP.NET behavior. You just need to add a line in your property set code to see if the inbound value is null and replace it with an empty string

If value Is Nothing Then value = String.Empty

Do this before comparing the value to your field.

 

Copyright (c) Marimer LLC