Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

i have a datagrid that displays two levels of information based on a relationship. The first level is simply dates, which link to the second level which is tasks associtated with that date. I want to also include a "total hours" column in the first level/parent datatable. What would be the best way to cycle through this hierarchy and get the total hours for each row related to each unique date? (please see attached file for a snapshot of the grid). So for the example I have attached, the "Total Hours" column in the first level will read "4".

 

i was thinking something along these lines:

 

Dim drow As DataRow

Dim trow As DataRow

Dim totalHours As Integer

For Each drow In das1.Tables("temp_Dates_table").Rows

For Each trow In das1.Tables("job_item_info").Rows

****totalHours = totalHours + das1.Tables("job_item_info").Columns("quantity") **** (this line is the concept only)

Next

das1.Tables("temp_Dates").Columns("hourstotal"). = totalHours

Next

 

[edit]Please use more sensibly sized attachments in future[/edit]

Edited by Squirm
Posted
Instead of iterating over DataRows, try using DataTable.Compute. Its second parameter accepts a filter criteria, a convenience for your problem :)
Posted
I looked at using the .compute function, but I wasn't quite sure how to apply it...Don't I still need to iterate through each row of the first table (dates) in order to get the total for the related rows for each individual date? :confused:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...