Solved

DataFormatString for time in asp.net

Posted on 2011-09-12
5
396 Views
Last Modified: 2012-05-12
trying to set the dataformatstring to time format to datetime

<asp:BoundField DataField="lateduration" HeaderText="Late Duration" DataFormatString="{0:t}" ItemStyle-Width="100px" HeaderStyle-BackColor="LightGray" />

but couldnt change its format.
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
5 Comments
 
LVL 5

Expert Comment

by:Didier Vally
ID: 36527446
0
 
LVL 7

Expert Comment

by:rashmi_vaghela
ID: 36527447
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 36528112
Hi
Please try below

<asp:BoundField DataField="lateduration" HeaderText="Late Duration" htmlEncode="false" DataFormatString="{0:t}" ItemStyle-Width="100px" HeaderStyle-BackColor="LightGray" />



Regards,
Ram
0
 
LVL 1

Accepted Solution

by:
doramail05 earned 0 total points
ID: 36533660
found out that the datetime is actually in string format,

therefore using the following :


string[] strSplitDuration = e.Row.Cells[5].Text.Split(' ');

            e.Row.Cells[5].Text = strSplitDuration[4];

            if (strSplitDuration[4] == "12:00AM")
            {
                e.Row.Cells[5].Text = "-";
            }

Open in new window

0
 
LVL 1

Author Closing Comment

by:doramail05
ID: 36555864
solved
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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