Solved

DataFormatString for time in asp.net

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now