Link to home
Start Free TrialLog in
Avatar of RyanBank
RyanBank

asked on

HierarGrid 3.9 Displaying one template for all child rows

Hi,

Please assist where do we place the code below..I'm lost on where I should place it. I'm using visual web developer 2005 express edition.

Thanks.

http://aspalliance.com/articleViewer.aspx?aId=21&pId=#Page1

>>>
3.9 Displaying one template for all child rows

You could change the Authors.ASCX file described above by dropping a DataGrid instead of a TextBox. In the code-behind you can then use the normal DataBinding syntax to bind a DataSet to the grid. This DataSet of child rows can be taken from the BindingContainer property:

[VB]
Dim dgi as DataGridItem = CType(Me.BindingContainer, DataGridItem)
Dim ds as DataSet = CType(dgi.DataItem, DataSet)
DG1.DataSource = ds
DG1.DataMember = "Authors"
DG1.DataBind()
<<<
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RyanBank
RyanBank

ASKER

on the site:
>>
3.9 Displaying one template for all child rows
The sample described above relies on displaying a template for each child row. E.g. when a book has two authors and has been sold three times the total number of templates loaded is five. Imagine you want to change this to display a nested DataGrid for all the authors and a DataGrid for all the sales under book.

This can be achieved by setting the TemplateDataMode to "Table" instead of "SingleRow" (its default value). Doing so loads only one template per child table.

You could change the Authors.ASCX file described above by dropping a DataGrid instead of a TextBox. In the code-behind you can then use the normal DataBinding syntax to bind a DataSet to the grid. This DataSet of child rows can be taken from the BindingContainer property:
[VB]
Dim dgi as DataGridItem = CType(Me.BindingContainer, DataGridItem)
Dim ds as DataSet = CType(dgi.DataItem, DataSet)
DG1.DataSource = ds
DG1.DataMember = "Authors"
DG1.DataBind()
<<

I have set the  TemplateDataMode to "Table" and created the Authors.ASCX manually since Visual webdeveloper can't open/create projects. where do I place that code he was saying? I already place a datagrid into the authors.ascx



I'm lost because I dont use code behind when editing. I use a straight down aspx file. where the subs are above the page ans html below. sorry for the confusion.