Solved

display different date format in ASP.NET gridview

Posted on 2010-11-11
4
1,202 Views
Last Modified: 2012-05-10
in gridview, it will display MM-dd-YYYY hh:mm:ss.000

try to show it in dd-MM-YYYY hh:mm:ss.000 instead.
0
Comment
Question by:doramail05
4 Comments
 
LVL 1

Accepted Solution

by:
mribasu earned 500 total points
ID: 34110122
in template field
<%#Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "CurrentLocDate")).ToString("dd-MM- yyyy hh:mm:ss tt")%>
0
 
LVL 15

Expert Comment

by:AmmarR
ID: 34110280
usually date format depends on regional settings

if you dont want to change the code

change the regional settings.

otherwise i would recommend formatting it manually to make sure it gets displayed the exact way you want like

check code below gets todays date in the format you like and stores it in a label
Label1.Text = Date.Today.Day & "-" & Date.Now.Month & "-" & Date.Now.Year & " " & Date.Now.Hour & ":" & Date.Now.Minute & ":" & Date.Now.Second & "." & Date.Now.Millisecond

Open in new window

0
 
LVL 6

Expert Comment

by:subhashpunia
ID: 34110287
0
 
LVL 1

Expert Comment

by:WingYip
ID: 34110310
change column in gridview to template field and add

<asp:TextBox ID="tbDate" runat="server" Text='<%# Bind("IssueDate","{0:dd-MMM-yyyy hh:mm:ss.000}") %>'></asp:TextBox>

or if its just for display

<asp:Label ID="Label1" runat="server" Text='<%# Bind("IssueDate","{0:dd-MMM-yyyy hh:mm:ss.000}") %>'></asp:Label>

Or something like that, you can change the format string to suit

wing
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now