M
Manish
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
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