This is a migrated thread and some comments may be shown as answers.

[Solved] How to automatically populate a field with the sum of values from a previous record?

2 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 27 Sep 2011, 07:36 AM
I have o datagrid with fields named "Start" and "Duration" like the rows drag and drop shipped orders one.
 When I add a new record I would like it to autopopulate the "Start" field with the "Start+Duration" value from the previous record (Start2=Start1+Duration1)

Example Recordset
Record 1, Start=0, Duration=500
Record 2, Start=500, Duration=1000
Record 3, Start=1500, Duration = 100
Record 4, Start=1600, Duration = 1500
...

How could i achieve this?

Thank you very much.


2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Sep 2011, 11:18 AM
Hello George,

You can try the following code library approach to get the last inserted value.
Select Last Inserted Row.

Thanks,
Shinu.
0
George
Top achievements
Rank 1
answered on 30 Sep 2011, 10:47 AM
Hello Shinu,

Thank you for your answer, but it is not very helpful. I would like when an update happens every start field to be calculated according to the value of previous start field. Something like this:


UpdateStart[i+1].Start= UpdateStart[i].Start + UpdateStart[i].Duration; (UpdateStart is a Generic List that has objects with properties Start and Duration, by the way this code is not working)

Should i convert my generic list to Datatable and make this or is there another way? Could i make this using radgrid calculated column?

Thank you very much.
Tags
Grid
Asked by
George
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
George
Top achievements
Rank 1
Share this question
or