Nesting A DataGrid Inside a Repeater

H

hooterbite

In the code behnd I build the dataset including the relations, which is
working fine. I know it is working fine becuase I tested it by looping
through the datatable then looping through the child table.
The code I use inside the datagrid is
<asp:DataGrid id="Datagrid1" runat="server" datasource='<%#
Container.DataItem.Row.GetChildRows("EntitiesDirectors") %>'

where EntitiesDirectors is the name of the datarelation.

Is this not the right syntax for a datagrid?

When I bind I get the following message

System.Web.HttpException: A field or property with the name 'FullName'
was not found on
the selected datasource

where FullName is the first field in the child table.
 
P

Patrick.O.Ige

The error you are getting says :-
System.Web.HttpException: A field or property with the name 'FullName'
was not found on
the selected datasource
Which means you haven't selected the column with the name 'FullName' from
your DB
is not in your datasource try adding it in your Query
Patrick
 
H

hooterbite

Patrick -
Thanks for your response, but as I said in my posting, the dataset and
relation are fine. I am able to loop through the parent table, then the
child table, and disply the field, so that is not the problem. The
problem is that the datagrid is not seeing the sub-table.
Josh
 
H

hooterbite

Here is the solution I used, which takes a slightly different approach.
Instead of setting the datasource in the grid, I do it when the mother
repeater is databinding

Public Sub BindMotherRepeater(ByVal sender As Object, ByVal e As
RepeaterItemEventArgs) Handles 'Name of Mother
Repeater'.ItemDataBound

Dim dvWhatever As DataView = e.Item.DataItem.CreateChildView("Name of
Data Relation")
Dim dgWhatever As DataGrid = e.Item.FindControl("ID of datagrid")
dgWhatever.DataSource = dvWhatever
dgWhatever.DataBind()

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top