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
Solved

DataFormatString for time in asp.net

Posted on 2011-09-12
5
393 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
No Data for DropDown List 2 27
linq, c# 8 22
Phone Does Not Abide By CSS Breakpoint For Navigation Controls 6 20
JQuery Detecting page post back 6 3
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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

789 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