how can i calculate total time in using c#

may i know how can i calculate the total time in using c# comprising hour minutes, and second
the example i could found in the Internet only add up hour and minutes.
string hour1="48:40";
string hour2 = "45:35";
TimeSpan ts = new TimeSpan(int.Parse(hour1.Split(':')[0]),int.Parse(hour1.Split(':')[1]),0);
TimeSpan ts1 = new TimeSpan(int.Parse(hour2.Split(':')[0]),int.Parse(hour2.Split(':')[1]),0);
TimeSpan total = ts + ts1;
and what does the [1] and [0] means
Posted On: Tuesday, November 27, 2012 Total Views: 168
View Complete with Replies

Related Messages:

How can i calculate some thing between two columns in a gridview control   (15 Views)
I have a easy gridview control on .aspx page. It has one combo box in the gridview control and rest of the columns in the gridview control are all bound controls.
When the user picks some thing from combo box I should multiply the number (picked from the combo box) with other number in the same row (meaning in a various column on the same row). I want to do all this in server controls not thru JQuery or Javascript. Here I am so far and
View Replies !
hwo to calculate dates between two dates   (20 Views)
is there any way to receive all dates b w two date for example
14 10 2010
22 10 2010
so there are 9 days b w two datesi wanted to do it
View Replies !
How can i calculate time difference   (27 Views)
For a project I am working on right now I want to be able to calculate the
time difference b/w to given times (24 hour format) and two given dates
For example:
Case 1: On the same date
The difference b/w 11:30 28 09 2005 and 14:45 28 09 2005 being 03:15
Case 2: On various date
The difference b/w 21:30 28 09 2005 and 10:45 29 09 2005 being 13:15Right now the input is setup as 5 text boxes (dateup, datedown, timeup, timedown, totaltimediff). Is it possible to use that configuration and somehow receive the time
difference The goal is to be able to enter the the date and time values and immediately view a calculated difference in a totaltimediff textbox.
I'm thinking the scenario is like this:
1. User enter date up in first text box(dateup) - 28 09 2005
2. User enter date down in second text box(datedown) - 29 09 2005
3. User enter time up in third text box(timeup) - 21:30
4. User enter time down in fourth text box(timedown) - 10:45
5. Onchange of fourth text box, the duration is calculated and result is inserted into fifth text box (totaltimediff).I'm uncertain if how can i bet do this.
View Replies !
ho to retreive totalrecords in   (8 Views)
i was attempting to retreive totalrecords and put it in a text feild
how can i do that
Please Assist
View Replies !
Re: creating calculated extra coulmn in a datagrid   (16 Views)

I wanna include a calculated column as part of my columns in the datagrid.
Let s say: the datagrid gets the columns: col1, col2, col3 from the database
I want to add another column in my datagrid: col4
But col4 will be: col4= col1 + col2 - col3 (just an example)
I guess I should do this in itemDataBound , right
But in itemDataBound How can I make that happen:
col4= col1 + col2 - col3
also, how should be the datagrid column: col4 defined in the datagrid aspx page: boundcolumn or itemTemplate
View Replies !
Math with .NET? total of gridview columns   (8 Views)

I was just tasked with making a gridview of a couple of columns.
Column one is a name and columnd 2,3 and more.. are check boxes that will indicate the task has been finished or not. What I have to do is at the bottom of the column or in a textbox display the done. I have never worked with the math in .net so I have no clue on how can i tally a row or column. Does anyone have any good resources to display how can i do this, or a small snippet of code snippet that will point me to the right direction I will be saving the data to a database that I do know how can i wirte and retrive the data, I am just now sure on how can i do the math.
View Replies !
summing total of datagrids   (12 Views)
http: showthread.p...hreadid=307621
View Replies !
recalculate in datagrid  (4 Views)

everybodyi want ur assist, is there anyone know how can i write the function will calculate the total for the items in datagrid.or do u have any related web site, u can send to me,ok
View Replies !
[RESOLVED] itemdatabound doubles total   (11 Views)
The framework using is 3.5.
Situation: I have a page that I call a stored procedure that returns two results. I create a dataset and then from that create two dataviews that one can have more than one records.
Problem: During the rptInvoice_itemDataBound of the repeater I am adding the amount value. The difficulty is it is always double what it should be. If I have one result with a total of $100 it displays $200. If I have two records each with $150 the total shown is $600. It is like its looping two times per row but only displaying the row once.
any thoughts on why my total is double
Here is my code snippet.
Dim cFn as clsfunctions = New clsfunctions
Dim cEncDec as clsEncryptDecrypt = New clsEncryptDecrypt
Private m_Total as Decimal
Public Property Total() as Decimal
Return m_Total
End Receive
Set(ByVal Value as Decimal)
m_Total = Value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
lblTotal.Text = Total
End If
End Sub
Private Sub sbFillPage(ByVal iPaypalTransactionID As Integer)
'Receive info for receipt page
Dim dsReceiptInfo As DataSet = cFn.fnGetReceiptInfo(iPaypalTransactionID)
Dim dvPaypalInfo As DataView = New DataView(dsReceiptInfo.Tables(0))
Dim dvInvoiceInfo As DataView = New DataView(dsReceiptInfo.Tables(1))
If dvPaypalInfo.Count > 0 Then
lblOrderNum.Text = iPaypalTransactionID
lblOrderDateTime.Text = dvPaypalInfo(0)("xxx")
lblFirstName.Text = dvPaypalInfo(0)("xxx")
lblLastName.Text = dvPaypalInfo(0)("xxx")
End If
lblInvoiceCount.Text = dvInvoiceInfo.Count
rptInvoice.DataSource = dvInvoiceInfo
End Sub
Protected Sub rptInvoice_itemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeateritemEventArgs) Handles rptInvoice.itemDataBound
If e.item.itemType = ListitemType.Header Then
Total = 0
End If
if ((e.item.itemType = ListitemType.item) _
OrElse (e.item.itemType = ListitemType.Alternatingitem)) Then
Total += CType(e.item.Dataitem, DataRowView)("invoice_amt")
End If
End Sub
HTML Code:
"rptInvoice" runat="server" OnitemDataBound="rptInvoice_itemDataBound">


View Replies !
Re: How do u display total number of rows in a table into a label?   (1 Views)
i am newbie.
i use sql server 2005 and Visual Studio 2008.
I am using and for my web site.
i have a table with number of rows 50000.
i want to display the number of rows at my table in a Label when the page is on load.
so can you provide me the code snippet or the hint thanks
my second question is.
my table has around 50,000 items.
and i have a search box, it look like this
str= select * from mytable where item='car'
the item Car is located in my table in row number of 45,000.
I think when i search from the table where the item is car, then it will search row by rows, then as the number of rows become huge, it will be so late to find the result.
so is there any method how can i search from table with good speed of searching
View Replies !
Re: [2005] Recalculate Formview on Formview Insert   (7 Views)
I have 2 formviews the first SELECTS the SUM of one of my fields in my tablr and displays the result in a label. The second contains a form that submits data into this table.
When i submit a new value into the second form i want the first form to update.
I recently have:
If IsPostBack Then
Dim formview3 as FormView = FormView1.FindControl("formview3")
End If
On SqlDataSource1_Inserted, imageButton1_Click, Page_Load aND Page_PreRenderComplete but it seems to be an insert behind in its calculation any ideas where i am going wrong
View Replies !
Re: Master Page totally loaded?   (4 Views)

How do I know if the masterpage is totally loaded
I amagine that u have a label in a masterpage with in it.
and one children of that masterpage needs the contents of that label u do this:Code snippet:
Protected Sub Page_LoadComplete(ByVal sender as Object, ByVal e as System.Eventargs) Handles Me.Load
lblDateinChildren.Text = CType(Master.FindControl("lblDateinMaster"), Label).Text
End Sub
But when the children page loads, there is no contents in lblDateinChildren.
I think that this occurs because the masterpage did not assign the contents to it is lblDateinMaster.
View Replies !
Re: automatically calculate and populate   (10 Views)

I am attempting to find way to automatically calculate and populate to Label
adding up two two textboxes and then automatically populate to Label.
I can receive it to work with onclick funtion but I really don't want that.
View Replies !
GridView - inserting total line in detail section   (26 Views)
I have a GridView that displays a list of cost codes for a specific job (see attached example). User wants to have a line inserted after each break on cost code snippet displaying total quantity (nned to add up quantity for each line). Is this possible any suggestion would be appreciated.
View Replies !
How can i calculate values of a datacolumn from 2 datatable values?  (11 Views)

I have a dataset with 2 dataTables named "Office" and "DriveInfo." The schema for "Office" is:Code snippet:" target="_blank">http: 2001 XMLSchema">;The schema for "DriveInfo" is:Code snippet:" target="_blank">http: 2001 XMLSchema">;I am adding a new datacolumn named "Changed" to the datatable programmatically.I want to calculate the values of datacolumn "Changed" programmatically. The values should be equal to Office.PercentFree - DriveInfo.PercentFree.Finally I want to bind the data to a datagrid that should have these columns: servername driveletter, Disk Size, Disk Free, Disk Used, Free, Changed , Office. Any assistance would be greatly appreciated
View Replies !
[2005] going totally nuts with user controls   (5 Views)
I'm going totally nuts here.
I hope somebody can assist me here I have been going nuts for 2 days now.
I have a page where I update and insert items. (for this particular web site it is horses.)
Each horse has a set of properties. I amade user controls for all properties.
all user controls contain a easy dropdownlist with inside:
value: an integer (FK to the property table inside the database)
display: the name of the property being read out the database
also before databinding the dropdownlist with values out of the database I have got a hard coded one : "NOT aVaILaBLE".
Not available will basically insert NULL inside the database row.
for inserting horses, I just put an html table inside a panel and put textareas, textbox, and all the user controls there. (I can thus call all these controls directly in my code-behind file)
INSERTING works perfectly. It is the updating part that is making me go nuts:
I now use these user controls as templatefields inside a formview (or detailview, I tried both) for the updating part.
Here is a small example:for inserting, an click-event is fired on the button "new"
all my values are checked or interchanged:Code snippet:
Dim ras As Object = RaceSelect1.SelectedRace
If Not ras.ToString = String.Empty Then
ras = CInt(RaceSelect1.SelectedRace)
ras = sqlintnull
End If
here if in my usercontrol, I selected a race that is in the database then it will use that value.
if instead "not available" is selected, the value for "not available" is empty and so a variable sqlintnull is entered.
this @ras is then used as a parameter for my stored procedure. I do this for about 15 parameters.
this work perfectly because these controls are not inside a detailview of formview.for updating (the info is thus already in the database) I need to show it in a formview of detailview. but if the user clicks "edit" he must be able to alter the values.
when in edit mode if the user chooses "not available" in the usercontrol dropdownlist I receive an invalid cast to error message because inside the dropdownlist it is a STRING and not DBNULL.
this is why I need :Code snippet:
Dim ras As Object = RaceSelect1.SelectedRace
If Not ras.ToString = String.Empty Then
ras = CInt(RaceSelect1.SelectedRace)
ras = sqlintnull
End If
but here instead as in inserted:Code snippet:
Dim RaceSelect1 as UserControl = CType(Formview1.FindControl("RaceSelect1"), UserControl)
Dim ras As Object = RaceSelect1.SelectedRace
If Not ras.ToString = String.Empty Then
ras = CInt(RaceSelect1.SelectedRace)
ras = sqlintnull
End If
(the bold does not work , I can't seem to receive into my public property meaning it does not recognises the user control)ok then I tried this:
I interchanged 1 usercontrol with a plain dropdownlist linked to a sqldataconnection.
if I then go to the code snippet behind : (didn't put all the code snippet, just the logic here )...
Code snippet:
and then
Code snippet:
it worksso why does not this also work on user controls ...Code snippet:
what is the use of usercontrols if this does not work
any assist would be great
View Replies !
executing total in asp updateable gridview  (17 Views)
This has been causing me grief for days. I placed here http: www.dreaminco...-and-gridviews but tsaid its more jsp or c# ..can anyone assist please
View Replies !
calculate number of days between two dates in MVC-3  (162 Views)

I have to count the days b/w given start and end dates in MVC-3
so how can i do this
code of my class files are:
set receive fileusing System;
using System.collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.Dataannotations;
using System.ComponentModel;
namespace LeaveModule.Models
public class LeaveSet

public int user_id { receive; set; }
[DisplayName("Start Date")]
public DateTime leave_start_date { receive; set; }
[DisplayName("End Date")]
public DateTime leave_end_date { receive; set; }
public string leave_description { receive; set; }
public decimal leave_days { receive; set; }

and code of 2nd class file for fetch the user data..
using System;
using System.collections.Generic;
using System.Linq;
using System.Web;
using ProjectManagementSystem.Models;
namespace LeaveModule.Models
public class LeaveSetfetch
TimeSpan ts;

public static IList all()
IList result =

if (result == null)

HttpContext.Current.Session["leave"] = result =
(from l in new ProjectManagementSystemEntities3().leave_master
select new LeaveSet
user_id = l.user_id
leave_start_date = l.leave_start_date,
leave_end_date = l.leave_end_date,
leave_description = l.leave_description,
ts = l.leave_end_date.Subtract(l.leave_start_date),
leave_days = l.leave_days,
is_valid = l.is_valid,
return result;
how to do these in mvc
View Replies !
how can i calculate the node of tree  (10 Views)
I am using i have create a tree with the assist of levels.
Now i want to count all member of particular member. How can i do that.
View Replies !
Label displays total  (6 Views)
I have got this code snippet:

I want amount_01 to display area_01 * rate_01 when the two textboxs' values's are entered and this is done with out a button.
How can I do this
View Replies !