Date Format

  • Thread starter Thread starter Mauricio
  • Start date Start date
M

Mauricio

In my webform has a text box bound with a DataSet's column
which type is DateTime.
I have 2 troubles:
- I want to show only date, but it's showing date and
time.
- I want to show date in format dd/mm/yyyy, but it's
showing mm/dd/yyyy.
Anyone can help me?

Thanks.
 
Or of course if I'd read the question correctly....

You'd probably be better using something like:

<%# DataBinder.Eval(Container.DataItem, "OrderDate", "{0:dd/MM/yyyy}" ) %>
 
For the first problem you can use ToShortDateString method of DateTime
object
for the second problem you can use <%# DataBinder.Eval(Container.DataItem,
"OrderDate", "{0:dd/MM/yyyy}" ) %>
 
Hi Pete,

How can I execute theDateTimeObject.ToString("dd/MM/yyyy")
if the text box is bound with a date column?

Best Regards,
Mauricio
 
In the DataBind event of the DataGrid, Place you code to convert the format.

private void dg_DataBind(object, e)
{
e.Items[3].Value = ((System.DateTime) e.Items[3]).ToString("dd/MM/yyyy",
System.Globalization.DateTimeFormatInfo.InvariantInfo)
}

Thanks,
Jagan Mohan
MCP
 
Back
Top