I have setup a Hierarchical Grid programmatically basically following the example in the Documentation. Now I need to update some Cells in the ChildGridView programmatically and assumed I can update the cell info with the following:
'-- The ChildGridView has already been populated with data |
Dim cTemplate As GridViewTemplate = GridViewPricing.MasterGridViewTemplate.ChildGridViewTemplates(0) |
'The following throws an error : |
'Object reference not set to an instance of an object. |
cTemplate.Rows(0).Cells(1).Value="somedata" |
Any help greatly appreicated.
9 Answers, 1 is accepted
The current architecture of RadGridView does not allow you to access/enter the data of the child rows/cells unless the parent row is expanded. This is done for optimization purposes. Basically, there are no child GridViewInfos created (unless the parent rows are expanded) initially which results in faster RadGridView.
You can still set the desired values to the child cells by following the approach demonstrates in this help article. Please note that you should know which is the parent row of the rows/cells that will have their values changed.
I hope this helps. If you have additional questions, feel free to contact me.
Greetings,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

Can any1 tell me how i can able to achieve the hierarchical grid programatticallly. Please provide me with the steps of doing the required task as i want to list only the selected columns from my master and child tables. a sample application will be of great help to me
also Plz tell me that how i can able to add the column in the child table dynamically at run time.
It will be very grateful of you.
Thank you for contacting us. Please refer to this help topic about creating a hierarchy programmatically. As to your second question about adding a column in the child template there are two options - you can add an unbound column or you can add a bound one. Adding columns to a child template is no different to adding a column in the master template. Please refer to the appropriate help topic about columns or unbound mode.
All the best,
Nick
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

i have studied the code but i can't able to imlement it. so if you can provide me with the sample applcation that will be quite a helpful
source for me. Moreover plz tell me the procedure of creating the hierarchy to three levels. i have able to achieve hierarchy at 2 levels by the examplegiven in your site. but not able to do at three levels.
Basically my program consist of three tables category, subcategory and product where category is the master table its child is subcategory and subcategory child is product table. i want to generate the hierarchy in that way. Plz provide me the steps of accomplishing it programmatically.
Waiting for your response
Regards:
SAHIL
Thank you for contacting us back. Creating a hierarchy of more than two levels is easy:
radGridView1.DataSource = nwindDataSet.Suppliers;
GridViewTemplate template =
new
GridViewTemplate();
template.DataSource = nwindDataSet.Products;
radGridView1.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
GridViewRelation relation =
new
GridViewRelation(radGridView1.MasterGridViewTemplate);
relation.ChildTemplate = template;
relation.RelationName =
"SuppliersProducts"
;
relation.ParentColumnNames.Add(
"SupplierID"
);
relation.ChildColumnNames.Add(
"SupplierID"
);
radGridView1.Relations.Add(relation);
...
You just need to create another template for the third level, set its appropriate data source, then add the new template, create a new relation between the second and the third level and add it to the Relations collection. Please send me your code if this is not helpful.
Also perhaps you can leave RadGridView to generate automatically your hierarchy instead of following the instructions in the previous paragraph.
Regards,
Nick
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

thanks a lot got the solution to create the hierarchical grid at three levels. i want to ask that is it possible that the headers of the child grid should appear only once. how can i able to achieve this functionality.
Moreover i want to know the procedure to add the column in the child templates at run time. plz provide me a sample application.
Waiting for a response
Regards:
SAHIL
The header row appears for each expanded child level, otherwise, it will be confusing for the end-user of your application. Can you send me a screenshot so that I can be sure that we are talking about the same thing.
As to your second question, I assume that you want to add an unbound column that you do not necessarily want to persist in your data base.
GridViewTextBoxColumn textBoxColumn =
new
GridViewTextBoxColumn();
textBoxColumn.HeaderText =
"Some name"
;
textBoxColumn.MaxLength = 50;
textBoxColumn.TextAlignment = ContentAlignment.BottomRight;
this
.radGridView1.MasterGridViewTemplate.ChildGridViewTemplates[0].Columns.Add(textBoxColumn);
The example above is again extract from our documentation. I changed only the last line -- instead of adding the new column to the MasterGridViewTemplate I added it to the first child template i.e. the second level in the hierarchy.
Regards,
Nick
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

please check my attached images(image-1 and image-2)
when i selecting "Diagnosis" or "Procedure"(pic-2,pic-3 in image-2) tab it produce an error like this (check pic-6 on image-2)
"Diagnosis" and "Procedure" have null datas.. thats the problem.
but image-1 all tabs have datas so its work fine.
note: when i select "Check out note" tab's value, its automatically select other tab's first row value.(see image-1 [5,6,7,8 pic] )
but in image-2 there only 2 tab(pic-1 and pic-4) have values. then i select "Check out note" tab's value(see pic-5 in image-2), ts ok no problem after it, i tried to select "Diagnosis" or "Procedure" tab that is empty tab, that time the error occure(see pic-6 in image-2)
how can i overcome this problem..
can i disable the row select option
Thanks
Shinu
You can try to set CurrentRow to null before changing the active view in hierarchy mode.
Next week we will introduce the new Q2 2010 release of RadControls with a changed and much improved RadGridView control. Feel free to try the new version and the new hierarchy model and let us know what you think. Your case most probably will not exist in the new version.
If you continue to experience the problem, please send us a simple project to debug the issue locally.
Julian Benkov
the Telerik team