Managed field, Nullable causing values to disappear

Managed field, Nullable causing values to disappear

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


cash_pat posted on Tuesday, March 03, 2009

Hi all,

I am stuck up deep in a fairly simple problem. Hope someone can help me out.

I have some textboxes bound to nullable decimals, ints etc. The problem is whenever i change a value in these controls and tab out they are reset to the previous values. I dont know what is happening. any ideas.

regards

cash pat

RockfordLhotka replied on Tuesday, March 03, 2009

Does the object property's setter get called (use the debugger to find out)?

If not, and I suspect not, then you have an issue at the UI level where data binding isn't handling this properly, and you probably need to tweak some settings on the textbox controls to tell them to support null values.

If the value does get to the setter, is the setter somehow throwing an exception? That may also cause odd behaviors - set blocks shouldn't throw exceptions, and if it is throwing then there's a bug somewhere (possibly in one of your validation rules).

cash_pat replied on Tuesday, March 03, 2009

The Setter is not being called. Also, i am binding it to a plain textbox control.

I am not aware of any properties on the windows textbox which need to be tweaked

thanks

RockfordLhotka replied on Tuesday, March 03, 2009

It has been a while since I looked at this sort of thing, but I think there
are properties on the textbox control dealing with how it handles null
values.

Rocky


-----Original Message-----
From: cash_pat [mailto:cslanet@lhotka.net]
Sent: Tuesday, March 03, 2009 10:35 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Managed field, Nullable causing values to disappear

The Setter is not being called. Also, i am binding it to a plain textbox
control.

I am not aware of any properties on the windows textbox which need to be
tweaked

thanks


cash_pat replied on Tuesday, March 03, 2009

Also, as i soon as i change my code to

Private Shared MinimumStockProperty As PropertyInfo(Of Integer) = RegisterProperty(GetType(InventoryItem), New PropertyInfo(Of Integer)("MinimumStock", "Minimum Stock", Nothing))
Public Property MinimumStock() As Integer
Get
Return GetProperty(Of Integer)(MinimumStockProperty)
End Get
Set(ByVal Value As Integer)
SetProperty(Of Integer)(MinimumStockProperty, Value)
End Set
End Property

it starts working !!

Copyright (c) Marimer LLC