Solved

display different date format in ASP.NET gridview

Posted on 2010-11-11
4
1,197 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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 1

Expert Comment

by:WingYip
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

9 Experts available now in Live!

Get 1:1 Help Now