473,385 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how do I display 221 seconds as 03:41 using DataFormatString

Hi:

I am pulling duration out of my DB and it returns duration in seconds. For
the display i would like to show it in time format with colon

So duration of 221 I want it to display 03:41

How do I work with the DataFormatString in my bound column to do this?
Anyone know?

Thanks!

Nov 19 '05 #1
7 2263
Stu
write your own custom function to mod on 60 for minutes and return the
rest as seconds

Nov 19 '05 #2
DataFormatString won't help. You should access the cell in either
ItemDataBound or PreRender event and format the value with something like
String.Format (..). You will have to convert the value to an integer, make
minutes and seconds parts and format them as separate decimals.

Eliyahu

"Tarren" <no***********@thanks.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
Hi:

I am pulling duration out of my DB and it returns duration in seconds. For the display i would like to show it in time format with colon

So duration of 221 I want it to display 03:41

How do I work with the DataFormatString in my bound column to do this?
Anyone know?

Thanks!

Nov 19 '05 #3
use a TimeSpan opbject and pass the '221' as the seconds parameter in the
contructor, you can then use the object to return the number of hours,
minutes, seconds, milliseconds

HTH

Ollie Riches

"Tarren" <no***********@thanks.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
Hi:

I am pulling duration out of my DB and it returns duration in seconds. For the display i would like to show it in time format with colon

So duration of 221 I want it to display 03:41

How do I work with the DataFormatString in my bound column to do this?
Anyone know?

Thanks!

Nov 19 '05 #4
Sorry about the messed up date - apparently it is not 1/13/2004 - I need
more sleep.

Thanks again for the help.
"Tarren" <no***********@thanks.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
Hi:

I am pulling duration out of my DB and it returns duration in seconds.
For
the display i would like to show it in time format with colon

So duration of 221 I want it to display 03:41

How do I work with the DataFormatString in my bound column to do this?
Anyone know?

Thanks!

Nov 19 '05 #5
Hi,

I did it using template columns. Since I bind directly to the reader and
not to a dataset, it was quicker, cleaner to do it in the aspx for my
current app than to do it in the db set.

Thanks all. Hope this helps someone else wanting to do something similar

<asp:TemplateColumn >
<ItemTemplate>
<%# Format((CLng(DataBinder.Eval(Container.DataItem, "duration")) -
(CLng(DataBinder.Eval(Container.DataItem, "duration")) Mod 60 )) / 60,"00")
%>
:
<%# Format(CLng(DataBinder.Eval(Container.DataItem, "duration")) Mod
60,"00") %>
</ItemTemplate>
</asp:TemplateColumn>

221 displays as 03:41 (i wanted the leading zero) :)

"Tarren" <no***********@thanks.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
Hi:

I am pulling duration out of my DB and it returns duration in seconds.
For
the display i would like to show it in time format with colon

So duration of 221 I want it to display 03:41

How do I work with the DataFormatString in my bound column to do this?
Anyone know?

Thanks!

Nov 19 '05 #6
this is a long one....you create a DateTime Instance, using the constructor
that allows you to specify seconds, and then call ToString giving it the
appropriate format string. I've not checked the syntax, but this should be
REALLY close....

<%# ctype(new
DateTime(0,0,0,0,0,ctype(dataitem,DataRowView)("du ration")),DateTime).ToStri
ng("mm:ss") %>

...note you don't have to use DataBinder.Eval when you're doing Databinding.
if you're binding to a datatable, the your DataItem is actually a
DataRowView, so you can get the value directly that way as an integer. The
DataBinder always returns Strings...therefore this would work is you wanted
to use the DataBinder Syntax...

<%# ctype(new
DateTime(0,0,0,0,0,Integer.Parse(DataBinder.Eval(C ontainer.DataItem,
"duration"))),DateTime).ToString("mm:ss") %>


"Tarren" <no***********@thanks.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Hi,

I did it using template columns. Since I bind directly to the reader and
not to a dataset, it was quicker, cleaner to do it in the aspx for my
current app than to do it in the db set.

Thanks all. Hope this helps someone else wanting to do something similar

<asp:TemplateColumn >
<ItemTemplate>
<%# Format((CLng(DataBinder.Eval(Container.DataItem, "duration")) -
(CLng(DataBinder.Eval(Container.DataItem, "duration")) Mod 60 )) / 60,"00") %>
:
<%# Format(CLng(DataBinder.Eval(Container.DataItem, "duration")) Mod
60,"00") %>
</ItemTemplate>
</asp:TemplateColumn>

221 displays as 03:41 (i wanted the leading zero) :)

"Tarren" <no***********@thanks.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
Hi:

I am pulling duration out of my DB and it returns duration in seconds.
For
the display i would like to show it in time format with colon

So duration of 221 I want it to display 03:41

How do I work with the DataFormatString in my bound column to do this?
Anyone know?

Thanks!


Nov 19 '05 #7
thanks! I'll give this one a try too. :)
"David Jessee" <dj*****@houston.rr.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
this is a long one....you create a DateTime Instance, using the
constructor
that allows you to specify seconds, and then call ToString giving it the
appropriate format string. I've not checked the syntax, but this should
be
REALLY close....

<%# ctype(new
DateTime(0,0,0,0,0,ctype(dataitem,DataRowView)("du ration")),DateTime).ToStri
ng("mm:ss") %>

..note you don't have to use DataBinder.Eval when you're doing
Databinding.
if you're binding to a datatable, the your DataItem is actually a
DataRowView, so you can get the value directly that way as an integer.
The
DataBinder always returns Strings...therefore this would work is you
wanted
to use the DataBinder Syntax...

<%# ctype(new
DateTime(0,0,0,0,0,Integer.Parse(DataBinder.Eval(C ontainer.DataItem,
"duration"))),DateTime).ToString("mm:ss") %>


"Tarren" <no***********@thanks.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Hi,

I did it using template columns. Since I bind directly to the reader and
not to a dataset, it was quicker, cleaner to do it in the aspx for my
current app than to do it in the db set.

Thanks all. Hope this helps someone else wanting to do something similar

<asp:TemplateColumn >
<ItemTemplate>
<%# Format((CLng(DataBinder.Eval(Container.DataItem, "duration")) -
(CLng(DataBinder.Eval(Container.DataItem, "duration")) Mod 60 )) /

60,"00")
%>
:
<%# Format(CLng(DataBinder.Eval(Container.DataItem, "duration")) Mod
60,"00") %>
</ItemTemplate>
</asp:TemplateColumn>

221 displays as 03:41 (i wanted the leading zero) :)

"Tarren" <no***********@thanks.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
> Hi:
>
> I am pulling duration out of my DB and it returns duration in seconds.
> For
> the display i would like to show it in time format with colon
>
> So duration of 221 I want it to display 03:41
>
> How do I work with the DataFormatString in my bound column to do this?
> Anyone know?
>
> Thanks!
>
>
>



Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Don | last post by:
I have a client page that employs hover buttons. They work just fine in IE. But, when using Netscape, they intermittently won't display. When they don't display, all that shows is a gray box the...
2
by: Rahul | last post by:
Hey Guys I have a development environment, in which the whole SQL syntax is stored in the Database. So the syntax in the databse column could be "where BirthDate = '12/31/2005' and ID =...
3
by: rajarya | last post by:
Hi, I m designing a HTML page(index.html),here i have 2 frames,by defult both frames have index1.html and index2.html as their source . in first frame(index.html) ,i have some redio buttons,and a...
1
by: pankhudi | last post by:
Hi,i am doing a graphics project (in C),wherein i need to display text.Obviously could have directly used outtextxy or other such functions but the problem is that i dont have to use stdandard...
2
by: Pradeep | last post by:
When using CSS to display an XML file as a table, is there a way to show the element names at the tops of the columns as headers? For Example : I have a XML file <ITEMLIST> <ITEM> <NAMEItem1 ...
1
by: raj | last post by:
Hi, can anyone help me in fetching the xml value from the table of column datatype xml,and i need to display the same using xslt and java. Thanks in Advance Raj
1
by: vineetbindal | last post by:
Hi all, I have a datagrid and detailsview. when a user selects a row in datagrid onSelectedIndexchanged is fired and Detailsview comes into picture. I want to display the data of the selected row...
3
by: btreddy | last post by:
Hiii experts , I've received one critical requirement from my customer this morning. I've a gridview,in one of my webpage, which displays all the prticipants who are participating in a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.