How to set new row values in a hierarchical grid

3 posts, 0 answers
  1. Roberto
    Roberto avatar
    7 posts
    Member since:
    Jan 2012

    Posted 06 Jan 2012 Link to this post

    Hi I have the following problem

    I have a hierarchical  whit a master detail row structure...When i click on Add new row in a Detail row i want get in the parent Row some values that are the primary key ...

    I'm trying to do so but does not work
     
    Private Sub radGridView1_DefaultValuesNeeded(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
             
            'here i get the parent row
            Dim row As GridViewRowInfo = TryCast(e.Row.ParentRow, GridViewRowInfo)
            If row IsNot Nothing AndAlso row.ParentRow IsNot Nothing Then
                 e.Row.Cells("ID").Value = row.ViewInfo.ParentRow.Cells("Ms_ProgRow").Value
            End If
     
        End Sub
    But the Master row is always nothing


    i try also to do get the parent cell value in this way

    e.Row.Cells("ID").Value= e.Row.ParentRow.Cells("Ms_ProgRow").Value
    but i got a null reference exception!

    How can i do this_?

    Thx
  2. Roberto
    Roberto avatar
    7 posts
    Member since:
    Jan 2012

    Posted 06 Jan 2012 Link to this post

    Ok...i foud the solution...

    for get the rows parent values i use this...

    e.Row.ViewInfo.ParentRow.Cells("Ms_ProgRow").Value

    and not  e.Row.ParentRow.Cells("Ms_ProgRow").Value (maybe is obsolete )



  3. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 11 Jan 2012 Link to this post

    Hello Roberto,

    I am glad to hear that you have found a solution for the issue. Yes, the ParentRow property is obsolete. You should use either the Parent property or the ParentRow property of the ViewInfo.

    If you have any other questions, please do not hesitate to write us.
     
    Greetings,
    Jack
    the Telerik team

    SP1
    of Q3’11 of RadControls for WinForms is available for download (see what's new).
Back to Top