Problems formatting a SmartDate in a GridView

Problems formatting a SmartDate in a GridView

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


dfeemster posted on Tuesday, June 26, 2007

I am displaying a list of business objects in a GridView control, but am running into some trouble formatting a SmartDate property.  I have disabled the HtmlEncode property for the column and have the DataFormatString property set to {0:MM/dd/yyyy hh:mm tt}, but the grid always displays the default format.  Is there something special that needs to be done to make this work for the SmartDate data type?

Thanks!

Danny

JoeFallon1 replied on Tuesday, June 26, 2007

You are supposed to use the SmartDate interally for your class and expose a String Property to the world in a Public Property. Then you can format the output of the SmartDate to a String in the Property Get using the Format String.

e.g.

Protected mTstamp As New Csla.SmartDate

Public Overridable Property Tstamp() As String
Get
 
mTstamp.FormatString = "MMM dd, yyyy hh:mm tt"
 
Return mTstamp.Text
End Get

etc.

Joe

Copyright (c) Marimer LLC