473,326 Members | 2,013 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,326 software developers and data experts.

Update to DataTable having Calculated Row

Hello Everyone
I am having weird problem in my datagrid bounded to datatable. My
datatable is populated from SQLServer database. DataGrid has
Calculated column Week% and Calculated record, SPLH.
An example of datagrid is

Category Amount Week%
Revenue 200
Cost 60 30
Hours 100
SPLH 2
Payroll 100
Benefit 30 30
Controllable 10 5

Record for category - Revenue, Cost, Hours, Payroll and Benefit is
extracted from database in SQL Server. These records are extracted
into a DataTable, which is binded to DataGrid. Also i have attached
Column Changing event to DataGrid on Column Week%.
Benefit is based on Payroll and Controllable/Cost is based on Revenue.
SPLH is calculated record based on Revenue/Hours and is inserted above
payroll. In column changing event, if i change Week% for category,
then amount is calculated as multiplying week% by category amount, on
which they are based. Therefore if we update week% for
Cost/Controllable, then Cost/Controllable amount changes by week% of
Revenue and same is for Benefit, which is based on Payroll.
Now if i change Cost/Controllable, then Amount and Week% gets updated
based on Revenue, which is above SPLH. For example if i update Cost
week% to 40, then DataGrid looks like-
Category Amount Week%
Revenue 200
Cost 80 40
Hours 100
SPLH 2
Payroll 100
Benefit 30 30
Controllable 10 5

But if i update Week% for Benefit to 50%, then amount gets updated for
benefit, which is based on payroll but week% is preserved. Also it
inserts new record for Benefit above SPLH with new value for Amount
and Week%.
Category Amount Week%
Revenue 200
Cost 80 40
Hours 100
Benefit 50 50
SPLH 2
Payroll 100
Benefit 50 30
Controllable 10 5

Also if i had Payroll above SPLH originally, something like
Category Amount Week%
Revenue 200
Cost 60 30
Hours 100
Payroll 100
SPLH 2
Benefit 30 30
Controllable 10 5

Then changing Week% for Benefit will result in,
Category Amount Week%
Revenue 200
Cost 60 30
Hours 100
Payroll 100
SPLH 2
Benefit 50 50
Controllable 10 5

I think for some reason, if a record is updated based on data above
calculated row, it works fine but if it is being updated based on
record after calculated record, it creates additional record above
first calculated record. Can anyone explain why so?

Thanks,
Manish
Nov 20 '05 #1
1 1908
Hi Manish,

I saw this question before in this newsgroup. Normaly this means that nobody
can help you.

I think in this case that the question is to complex for a newsgroup.

However a new row will be normaly created by a:
datatable.rows.add(...)
datatable.rows.insertat()
currencymanager.addnew

You can have a look of one of those is in your program

I hope this helps?
Cor
Nov 20 '05 #2

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

Similar topics

3
by: Bill Clark | last post by:
I have about 20,000 records pulled from Excel that I need to update. What I need to do is run an update query that bascially says: If a field is null, update it with the previous record value of...
2
by: Joseph Markovich | last post by:
I'm having some trouble with VB in Access 2000. I have a form that the user enters in just one number (in this case, it's a base salary) and then the program is going to do a bunch of math (which...
2
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
1
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
9
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from...
0
by: Manish | last post by:
Hey Guys I am using a datagrid to extract information out of SQL Server datbase. The fields extracted are category,week,budget,Last Year,Forecast and Projection. Also i add a calculated column...
11
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
4
by: George | last post by:
Hi all, I am having trouble with updating my data in an Access database. here is my code: Imports System.Data.OleDb Dim AppPath As String = Mid(Application.ExecutablePath, 1,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.