473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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
Nov 16 '05 #1
3 4524
If you are using DataBinder.Eval(), pass the required formatting for the 3rd
parameter. In case of BoundColumn, use DataFormatString attribute.

HTH

"Jim H" <no****@jimsaccount.com> wrote in message
news:O1**************@tk2msftngp13.phx.gbl...
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

Nov 16 '05 #2
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" <sh******@online.excite.com> wrote in message
news:ud**************@TK2MSFTNGP15.phx.gbl...
If you are using DataBinder.Eval(), pass the required formatting for the
3rd
parameter. In case of BoundColumn, use DataFormatString attribute.

HTH

"Jim H" <no****@jimsaccount.com> wrote in message
news:O1**************@tk2msftngp13.phx.gbl...
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

Nov 16 '05 #3
Never mind I got it.
Needed "{0:MM/dd/yy HH:mm:ss:fff}"
"Jim H" <no****@jimsaccount.com> wrote in message
news:O3**************@TK2MSFTNGP11.phx.gbl...
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" <sh******@online.excite.com> wrote in message
news:ud**************@TK2MSFTNGP15.phx.gbl...
If you are using DataBinder.Eval(), pass the required formatting for the
3rd
parameter. In case of BoundColumn, use DataFormatString attribute.

HTH

"Jim H" <no****@jimsaccount.com> wrote in message
news:O1**************@tk2msftngp13.phx.gbl...
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


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: karunakar | last post by:
Hi All I was poplating Datagrid Datagrid has one of the column showing datetime field format iam showing DATE here not Necessary to populate the Time Frame Even my datebase column also...
2
by: Roger | last post by:
I have a datagrid with a column bound to a date field. Is there a way to format the date field?
4
by: Paul | last post by:
Hi, Everything went fine getting a short date format out of SQL into my DataGrid with this: <%# DataBinder.Eval(Container.DataItem, "Created", "{0:d}")%> Then I got too fancy in SQL and...
5
by: William Gower | last post by:
I have a datagrid that has a column that displays a date. The date is currently being displayed in a long format, I want to format it to display in short format. How do I do that in a datagrid?
1
by: JAPHET | last post by:
I am Trying to Format date in my Datagrid to SHORTDATE format with the following codes, Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As...
4
by: yer darn tootin | last post by:
Does anyone know the sort expression for a column that's data has been returned in the format, eg '07 Jul 05'?? The sort expression {..:"dd mmm yy"} doesn't work ( if the column was returned as...
9
by: Shapper | last post by:
Hello, I created a dataset from a XML file. One of the dataset fields is . In an ASP:Repeater I am displaying the field. <%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %> The...
1
by: Lurc | last post by:
Hi all, One field of Access table is date/time type, and format is long time. In VB.NET, as this table linked to a datagrid, a strange date 12-30-1899 is shown instead of the time expected....
6
by: yoshitha | last post by:
hi db : sql server 2000 lan : C#.net(ASp.Net) in my database table there are 2 fileds of data type datatime. in field 1 i'm storing date in field 2 i'm storing time.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.