ASP/DataGrid/BoundColumn/Data formatting expression fo Date?

  • Thread starter Volodymyr Lozovoy
  • Start date
V

Volodymyr Lozovoy

Hi All,

who suggest why subj do not affect on displayed result for date?
 
V

Volodymyr Lozovoy

I think so :)
but where?

Data format expression is {0:d}- short date format "05/06/04" (it is wrote
in help "Properties for Bound Columns"), but date is rendered as May 6 2004.
 
E

Eliyahu Goldin

If you look in the help for BoundColumn.DataFormatString, you will find that
D (or d) displays numeric values in decimal format. It shouldn't affect date
fields, which is what you are observing.

You can format dates in code-behind in either ItemDataBound or PreRender
event. Get the cell text, convert it to DateTime and format it back to
string with format expression of your choice.

Eliyahu
 
V

Volodymyr Lozovoy

I am newbie in .NET. May be i am wrong.
I agree with you about numeric value, but i have date value.
In the help for Standard DateTime Format Strings "d" is short date pattern.
 
V

Volodymyr Lozovoy

Thank you! I found my mistake.

Eliyahu Goldin said:
If you look in the help for BoundColumn.DataFormatString, you will find
that
D (or d) displays numeric values in decimal format. It shouldn't affect
date
fields, which is what you are observing.

You can format dates in code-behind in either ItemDataBound or PreRender
event. Get the cell text, convert it to DateTime and format it back to
string with format expression of your choice.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,269
Messages
2,571,097
Members
48,773
Latest member
Kaybee

Latest Threads

Top