Solved

use SUM and date difference in the datagrids with a dataset

Posted on 2003-12-06
3
252 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery + C#.net radiobuttonlist 3 46
Where does legacy ASP.NET initialize language? 2 62
How to repeat the data 4 30
locate sql commands in C# visual studio Project 6 44
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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