?
Solved

DataFormatString for time in asp.net

Posted on 2011-09-12
5
Medium Priority
?
417 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

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