>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.