Solved

display different date format in ASP.NET gridview

Posted on 2010-11-11
4
1,218 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 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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