SmartDate Formatting in a FormView

SmartDate Formatting in a FormView

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


fark posted on Saturday, January 02, 2010

I have a formview that has a textbox that I have bound to a DateTime field. I only want to see the Time portion of the DateTime but this bind statement does not work: Text=' Bind("TimeRec", "{0:HH:mm tt}") ' (I had to take out the brackets so the code would show up in the forum post) Is this because the SmartDate field shows up as a string on the formview? Does the Bind formatting only work on DateTime fields? Am I doing something wrong? How does everyone deal with this?

Marjon1 replied on Saturday, January 02, 2010

Is the propert that you are bound to an acutal datetime or is it a string? The 'normal' CSLA approach is to expose it as a string and therefore I wouldn't be surprised that your mask doesn't work. You could change your property to be a DateTime propert and return the Date property from the SmartDate field. You would lose the ability to enter things such as today, yesterday, etc but I don't think that would be s problem givgn that you are dealing only with time.

The other option is to change the string format of your string property do that it only gives the time string if that us all that you are interested in. However, that depends on how your object is used outside of the form.

John

fark replied on Monday, March 01, 2010

I forgot to write back and thank you.  Changing the type to a datetime worked with the mask.

Thanks!

Copyright (c) Marimer LLC