Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

display different date format in ASP.NET gridview

Posted on 2010-11-11
4
Medium Priority
?
1,237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
mribasu earned 2000 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

730 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