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

How to set new row values in a hierarchical grid

2 Answers 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Roberto
Top achievements
Rank 1
Roberto asked on 06 Jan 2012, 12:33 PM
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 Answers, 1 is accepted

Sort by
0
Roberto
Top achievements
Rank 1
answered on 06 Jan 2012, 12:52 PM
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 )



0
Jack
Telerik team
answered on 11 Jan 2012, 11:09 AM
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).
Tags
GridView
Asked by
Roberto
Top achievements
Rank 1
Answers by
Roberto
Top achievements
Rank 1
Jack
Telerik team
Share this question
or