Print Page | Close Window

Save Nullable(of integer)

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2873
Printed Date: 28-Jun-2026 at 5:22am


Topic: Save Nullable(of integer)
Posted By: Togas
Subject: Save Nullable(of integer)
Date Posted: 08-Aug-2011 at 8:17am
In my database I have an interger field that can be null.

In my page I'm showing that field in a textbox like this:

<TextBox Text="{Binding Document, Mode=TwoWay}" />

If I give it a value (say "1") and save it works fine.  But if I then clear the textbox and save the value stays as "1".  How do I get around this?

Thanks





Replies:
Posted By: DenisK
Date Posted: 08-Aug-2011 at 2:09pm
Hi Togas;

I suspect that it might be a problem with the view. I did a test with this scenario and couldn't repro this issue. In my test, I cleared the textbox, did a save, and the corresponding nullable field shows null in both my view and the database.

My suggestion to debug this is to put a breakpoint inside your SaveChangesAsync callback and inspect the EntitySaveOperation.Entities argument.

You can download my test in the link below. I'm using the NorthwindIB database that comes with every DevForce installation. In my test, I'm modifying a Customer.RowVersion field which is a nullable integer in the model.

http://www.ideablade.com/friends/Silverlight_AddingDeleting.zip - www.ideablade.com/friends/Silverlight_AddingDeleting.zip

My test is an extended version of this code sample.  http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-add-delete-silverlight - http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-add-delete-silverlight . I just modified the sample to include the Customer.RowVersion in the view. Everything else stays the same.

Hope this helps.


Posted By: Togas
Date Posted: 09-Aug-2011 at 6:22am
You were right, it was my view.

Thanks, the sample code helped.



Print Page | Close Window