New Posts New Posts RSS Feed: Save Nullable(of integer)
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Save Nullable(of integer)

 Post Reply Post Reply
Author
Togas View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Jul-2011
Location: Minneapolis
Posts: 11
Post Options Post Options   Quote Togas Quote  Post ReplyReply Direct Link To This Post Topic: Save Nullable(of integer)
    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


Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post 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.

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. I just modified the sample to include the Customer.RowVersion in the view. Everything else stays the same.

Hope this helps.
Back to Top
Togas View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Jul-2011
Location: Minneapolis
Posts: 11
Post Options Post Options   Quote Togas Quote  Post ReplyReply Direct Link To This Post Posted: 09-Aug-2011 at 6:22am
You were right, it was my view.

Thanks, the sample code helped.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down