Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1380
wingrid parentrow value
posted
Helli, How to get ParentRow cell value from childrow. when I try code below it copies to all rows the same value.But I need every row to get its parent row cell value. e.Row.Cells[2].Value = e.Row.ParentRow.Cells[1].Value; thanks.
Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    I'm not really sure what you are asking.

    The code you have posted here appears to be placed in the InitializeRow event. This event will fire for every row, so this code will blow up, because the event will fire for the parent rows and the ParentRow of a root-level row will be null. So I assume you must be checking which band the row is in or checking for ParentRow == null.

    Assuming all of that is the case, then the code you have here will copy the value of Cells[1] in the parent row into Cells[2] of the child row. That seems to be what you want, so I am really not sure what your question is.

    Also, using the cell index is generally not a good idea. You should probably use the column key instead. The index will change based on the location of the column. So if the user moves the columns around, this code will have unpredictable results.

Children
No Data