Avatar of doramail05
doramail05
Flag for Malaysia asked on

display different date format in ASP.NET gridview

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.
Microsoft SQL Server 2008ASP.NET

Avatar of undefined
Last Comment
WingYip

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mribasu

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AmmarR

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

subhashpunia

WingYip

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck