Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting mmTextBox.DisplayFormat property
Message
 
To
18/05/2004 15:29:02
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00905073
Message ID:
00905465
Views:
25
>I have a web form with an optional date field.
>
>1) I want a SQL datetime field retrieved into a mmTextBox displayed in a short format.
>
>Setting the mmTextBox.DisplayFormat property to "d" for short date results in the field value contaning: "d".
>
>What expression idiom do I use to set mmTextBox.DisplayFormat?

Same as String.Format. {0:d} for example. Internally String.Format is used and the 0 corresponds to the value that is being bound. So you can do funky things like:

{0:d} PST

for example as the string is a full format string.

You have to be careful with your formats though. The formats have to be convertable back into teh underlying data type when you save. So if you do something like the above (adding a PST designator) you'll likely have to strip that off first before saving.



>
>2) Also, a "String was not recognized as a valid DateTime." warning gets fired when the value is left blank. Is there an easy way to override this, or do I need to create a custom business rule?

We're working on a way to deal with this, but htis is a general problem with .Net controls that they don't understand null values and right now you need custom logic to deal with this. For dates I tend to use MinDate values and check for that as empty.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform