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

Looping the childgridviewtemplates childrows

2 Answers 55 Views
GridView
This is a migrated thread and some comments may be shown as answers.
gerbrand
Top achievements
Rank 2
gerbrand asked on 30 Mar 2009, 04:54 PM
Hi,

I have a hierarchy in the gridtable view.
Now I want to get the childrows of the selected items in the mastergridviewtemplate.

Like this:
foreach (var masterrow in rgvAdserverNetwork.MasterGridViewTemplate.Rows) 
    var childRows = masterrow.ViewTemplate.ChildGridViewTemplates[0].GetChildRows(masterrow); 
    foreach( var child in childRows) 
    { 
      foreach(GridViewCellInfo cell in child.Cells) 
      { 
        Console.WriteLine(cell.Value); 
      } 
    } 

Now I get an NullReference on the cell.Value.

When I look in de debugger the child.Cells.Count is triggering this.

What am I doing wrong here?

Tried several things, everytime the same error...

Thanks a lot in advance

2 Answers, 1 is accepted

Sort by
0
gerbrand
Top achievements
Rank 2
answered on 31 Mar 2009, 07:31 AM
Okay I found the solution on the forum.

Had to take a better look at the forum before posting this question.

The thing is that you have to expand the childs. 

Here is it explained:


This sentence should be added in the help files under the subject : "Iterating the child rows collection of a chosen parent row inhierarchy RadGridView"

=> "To access the child row cells you have to expand hierarchy before iterating. So IsExpanded=true is needed, because RadGridView uses virtualization. Child cells do not get create before the child view is expanded."


0
Nick
Telerik team
answered on 31 Mar 2009, 09:24 AM
Hello gerbrand,

Thank you for contacting us. There is an online documentation topic about your question. Do not hesitate to write us back if you have further questions.
 

Sincerely yours,
Nick
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
gerbrand
Top achievements
Rank 2
Answers by
gerbrand
Top achievements
Rank 2
Nick
Telerik team
Share this question
or