How do I set the date format in a webui datagrid column?

  • Thread starter Thread starter Jim H
  • Start date Start date
J

Jim H

I have a datagrid on a web form that is bound to a datatable that has a
column with datetime values. The default format is displaying the date and
time down to the second. I'd like to display the time down to the
millisecond as well as change the default for some other parts of the
datetime.
So instead of this:
MM/dd/yyyy hh:mm:ss

I'd like to display it like this:
MM/dd/yy HH:mm:ss:fff

Any ideas?

jim
 
If you are using DataBinder.Eval(), pass the required formatting for the 3rd
parameter. In case of BoundColumn, use DataFormatString attribute.

HTH

I have a datagrid on a web form that is bound to a datatable that has a
column with datetime values. The default format is displaying the date and
time down to the second. I'd like to display the time down to the
millisecond as well as change the default for some other parts of the
datetime.
So instead of this:
MM/dd/yyyy hh:mm:ss

I'd like to display it like this:
MM/dd/yy HH:mm:ss:fff

Any ideas?

jim
 
I'm using bound columns. The DataFormatString doesn't work.
I have this:
int liTimeStampIndex =
m_DataSet.Tables[lsTableName].Columns.IndexOf("time_stamp");
((BoundColumn)m_dgLogData.Columns[liTimeStampIndex]).DataFormatString =
"MM/dd/yy HH:mm:ss:fff";

The columns displays "MM/dd/yy HH:mm:ss:fff" instead of the time values now.

What am I missing?
jim
 
Never mind I got it.
Needed "{0:MM/dd/yy HH:mm:ss:fff}"
Jim H said:
I'm using bound columns. The DataFormatString doesn't work.
I have this:
int liTimeStampIndex =
m_DataSet.Tables[lsTableName].Columns.IndexOf("time_stamp");
((BoundColumn)m_dgLogData.Columns[liTimeStampIndex]).DataFormatString =
"MM/dd/yy HH:mm:ss:fff";

The columns displays "MM/dd/yy HH:mm:ss:fff" instead of the time values
now.

What am I missing?
jim

Shiva said:
If you are using DataBinder.Eval(), pass the required formatting for the
3rd
parameter. In case of BoundColumn, use DataFormatString attribute.

HTH

I have a datagrid on a web form that is bound to a datatable that has a
column with datetime values. The default format is displaying the date
and
time down to the second. I'd like to display the time down to the
millisecond as well as change the default for some other parts of the
datetime.
So instead of this:
MM/dd/yyyy hh:mm:ss

I'd like to display it like this:
MM/dd/yy HH:mm:ss:fff

Any ideas?

jim
 
Back
Top