R
Rob Roberts
I have a GridView that is bound to a collection of DateTimes (i.e. -
Collection<DateTime>). I have a BoundField in the GridView, and its
DataField is set to the DateTime's Date property, and the DataFormatString
is set to "{0:d}" in order to display the date in short date format (without
the time). But the DataFormatString doesn't seem to have any effect. The
DateTime gets displayed with the time.
I have another GridView that is bound to a collection of business objects,
and the business objects have a DateTime property. One of the columns in
the GridView has a BoundField that uses this DateTime property as its
DataField. In this case, the "{0:d}" DataFormatString works as it should.
(The DateTime is displayed in short date format, without the time.) So it
works in this case, but not when I have the GridView bound to a collection
of DateTimes.
I've worked around the problem by using the RowDataBound event to manually
trim the time from the end of the cell's text, but that's a kludgy
workaround. Does anyone know why the DataFormatString isn't working
correctly in this case?
Thanks in advance,
--Rob Roberts
Collection<DateTime>). I have a BoundField in the GridView, and its
DataField is set to the DateTime's Date property, and the DataFormatString
is set to "{0:d}" in order to display the date in short date format (without
the time). But the DataFormatString doesn't seem to have any effect. The
DateTime gets displayed with the time.
I have another GridView that is bound to a collection of business objects,
and the business objects have a DateTime property. One of the columns in
the GridView has a BoundField that uses this DateTime property as its
DataField. In this case, the "{0:d}" DataFormatString works as it should.
(The DateTime is displayed in short date format, without the time.) So it
works in this case, but not when I have the GridView bound to a collection
of DateTimes.
I've worked around the problem by using the RowDataBound event to manually
trim the time from the end of the cell's text, but that's a kludgy
workaround. Does anyone know why the DataFormatString isn't working
correctly in this case?
Thanks in advance,
--Rob Roberts