Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

use SUM and date difference in the datagrids with a dataset

Posted on 2003-12-06
3
Medium Priority
?
266 Views
Last Modified: 2010-04-16
using windows application.

first form details:  two datagrids--first for main table, second for sub table (they are related in dataset)
how do I sum the column containing rows of numbers into a single row of total amount in the "sub table" datagrid ?

second form:  same as above.  
how do I set up the date difference--"sub table" datagrid with three columns (col 1 - previous date, col 2 - current date, col 3 - date difference by DAYS)

the data comes from a xml file and is stored in the dataset.  I don't know if i need to do something with xml schema...

hope these details help...thanks
0
Comment
Question by:rizel
[X]
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
3 Comments
 
LVL 20

Accepted Solution

by:
TheAvenger earned 2000 total points
ID: 9895036
First problem: handle the DataGrid.CurrentCellChanged for the main grid, thus finding the moment when the records in the sub table changed. You will then be able to get the current row in the main DataGrid. Use the DataRow.GetChildRows to get the rows that are shown in the related child table and calculate manually the sums. Add a new row to the child table including the summed values. Be careful: maybe you will have to clear the previous sum row.

Links:
- DataGtrid.CurrentCellChanged: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridclasscurrentcellchangedtopic.asp
- DataRow.GetChildRows: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatarowclassgetchildrowstopic.asp

Second problem: create a table with two columns for the two dates you want to calculate the difference from. Then create a third column and use SQL statements to set the DataColumn.Expression property to calculate the value of the third column. You will have to play a little bit with the expression because directly subtracting the columns will probably return the difference in millilseconds.

Links:
- DataColumn.Expression: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataColumnClassExpressionTopic.asp
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

636 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