locked
update child from master RRS feed

  • Question

  • hi,

    if i have a master record which has a value for area ie, 200 sqft

    and i have a datagrid with child records and need to use the above field value in a compute value in the child grid like so

    master : 200

    child:  

    $2000 : $2000\200 = 10

    $3000 : $3000\200 = 15

    if the values changes on the master from 200 to 250 the child records need to update as well ( dynamically on the screen)

    normally i would use a computed value for the division - but can't cause the value to divide by, isn't in the child dataset

    Can I insert a column into the datagrid on data binding to contain the calculated values ? how ? or is there another way ?

    thanks

    MrP

    Wednesday, January 22, 2014 6:34 PM

Answers

  • Hi

    You can directly compute your child record based on parent value.

    Let's say

    Parent Property Value = 200

    Child Property Value = 2000 & 3000 respectively.

    In child table create a compute column and write the below code within the method.

    if (Parent != null)
    {
       if (Parent.ParentPropertyValue > 0)
       result = Parent.ParentPropertyValue/ChildPropertyValue;
    }
    Change the name as per your requirement.
    Regards


    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.



    • Edited by babloo1436 Thursday, January 23, 2014 3:46 AM
    • Marked as answer by mrP Thursday, January 23, 2014 7:02 PM
    Thursday, January 23, 2014 3:45 AM

All replies

  • Hi

    You can directly compute your child record based on parent value.

    Let's say

    Parent Property Value = 200

    Child Property Value = 2000 & 3000 respectively.

    In child table create a compute column and write the below code within the method.

    if (Parent != null)
    {
       if (Parent.ParentPropertyValue > 0)
       result = Parent.ParentPropertyValue/ChildPropertyValue;
    }
    Change the name as per your requirement.
    Regards


    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.



    • Edited by babloo1436 Thursday, January 23, 2014 3:46 AM
    • Marked as answer by mrP Thursday, January 23, 2014 7:02 PM
    Thursday, January 23, 2014 3:45 AM
  • mmmh, i tried that

    in the partial class for the child data table

    i get this,

     partial void PSF_Compute(ref string result)
            {
                if(Parent != null)

    the name "Parent does not exist in the current context"

    ? am i in the wrong place ?

    Thursday, January 23, 2014 3:50 PM
  • Hi

    I believe that your PSF computed property is in child entity. As I told you earlier change the name as per your schema. Here Parent means your parent entity which is one to many relation with your child entity.

    Regards


    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.

    Thursday, January 23, 2014 6:11 PM
  • sorry i thought you were telling me there was a built in way to get teh child entity parent by using keyword 'Parent'

    oops :)

    Thank you

    Thursday, January 23, 2014 7:02 PM