[color=blue]
>-----Original Message-----
>Doh! The HTML has all been rendered . . .
>
>Right click on this link and select 'Save target as ..'
>to get the code in a text file.
>
>Thanks - Ed
>[color=green]
>>-----Original Message-----
>>I have created an ASP.Net page - see code below -[/color]
>adapted[color=green]
>>from http://support.microsoft.com/default.aspx?[/color]
>scid=kb;EN-[color=green]
>>US;306154 which contains 3 repeaters nested inside of
>>each other.
>>
>>When it executes it throws an InvalidCastExce ption when
>>getting the datasource of the grandchild repeater.
>>However this datasource is fine for the child repeater -[/color][/color]
[color=blue][color=green]
>>remove the grandchild repeater from the page and it[/color][/color]
runs[color=blue][color=green]
>>as expected.
>>
>>Can anyone tell me what is wrong with the datasource of
>>the grandchild repeater? What should it be?
>>
>>Thanks - Ed
>>
>>
>>HTML file:
>>==========
>><code>
>>
>><%@ Page language="c#"
>>Codebehind="N estedRepeater.a spx.cs"
>>AutoEventWire up="false"
>>Inherits="Nes tedRepeater.Nes tedRepeater" %>
>><%@ Import Namespace="Syst em.Data" %>
>>
>><html>
>><head>
>><title>Nest ed Repeater Example</title>
>></head>
>><body>
>><form runat="server" id="Form1">
>>
>><!-- start parent repeater -->
>><asp:repeat er id="parentRepea ter" runat="server">
>> <itemtemplate >
>> <b>Company : <%# DataBinder.Eval
>>(Container.Da taItem,"Company Name") %></b><br/>
>>
>> <!-- start child repeater -->
>> <asp:repeater id="childRepeat er" datasource='<%#
>>((DataRowView )Container.Data Item).Row.GetCh ildRows
>>("Customers_O rders") %>' runat="server">
>>
>> <itemtemplate >
>> - Order Date : <%# DataBinder.Eval
>>(Container.Da taItem, "[\"OrderDate\ "]")%><br/>
>>
>> <!-- start grandchild repeater -->
>> <asp:repeater id="grandChildR epeater"
>>datasource='< %# ((DataRowView)
>>Container.Dat aItem).Row.GetC hildRows
>>("Orders_Orde rDetails") %>' runat="server">
>> <itemtemplate >
>> - - Product ID : <%#
>>DataBinder.Ev al(Container.Da taItem, "[\"ProductID\ "]")%[color=darkred]
>>><br>[/color]
>> </itemtemplate>
>> </asp:repeater>
>> <!-- end grandchild repeater -->
>>
>> </itemtemplate>
>> </asp:repeater>
>> <!-- end child repeater -->
>>
>> </itemtemplate>
>></asp:repeater>
>><!-- end parent repeater -->
>>
>></form>
>></body>
>></html>
>>
>></code>
>>
>>Code behind file:
>>============= ====
>><code>
>>
>>using System;
>>using System.Data;
>>using System.Data.Sql Client;
>>using System.Web;
>>using System.Web.Sess ionState;
>>using System.Web.UI;
>>using System.Web.UI.W ebControls;
>>
>>namespace NestedRepeater
>>{
>> public class NestedRepeater : System.Web.UI.P age
>> {
>> protected
>>System.Web.UI .WebControls.Re peater parentRepeater;
>>
>> public NestedRepeater( )
>> {
>> Page.Init += new
>>System.EventH andler(Page_Ini t);
>> }
>>
>> public void Page_Load(objec t sender,
>>EventArgs e)
>> {
>> //Create the connection and
>>DataAdapter for the Customers (parent) table.
>> SqlConnection cnn = new
>>SqlConnection ("Data Source=(local); Integrated
>>Security=SSPI ;Trusted_Connec tion=yes;Initia l
>>Catalog=North wind;");
>> SqlDataAdapter daCustomers = new
>>SqlDataAdapte r("select CustomerID, CompanyName from
>>Customers order by CompanyName", cnn);
>>
>> //Create a second DataAdapter for
>>the Orders (child) table.
>> SqlDataAdapter daOrders = new
>>SqlDataAdapte r("select OrderID, CustomerID, OrderDate
>>from Orders order by OrderDate", cnn);
>>
>> //Create a third DataAdapter for
>>the OrderDetails (grandchild) table.
>> SqlDataAdapter daOrderDetails =
>>new SqlDataAdapter( "select OrderID, ProductID from[/color]
>[Order[color=green]
>>Details] order by OrderID", cnn);
>>
>> //Create and fill the DataSet.
>> DataSet ds = new DataSet();
>> DataTable dtCustomers =
>>ds.Tables.Add ("Customers" );
>> DataTable dtOrders = ds.Tables.Add
>>("Orders");
>> DataTable dtOrderDetails =
>>ds.Tables.Add ("OrderDetails" );
>> daCustomers.Fil l(dtCustomers);
>> daOrders.Fill(d tOrders);
>> daOrderDetails. Fill
>>(dtOrderDetai ls);
>>
>> //Create the relation between the
>>Customers and Orders tables.
>> ds.Relations.Ad d
>>("Customers_O rders", ds.Tables["Customers"].Columns
>>["CustomerID "], ds.Tables["Orders"].Columns
>>["CustomerID "]);
>>
>> //Create the relation between the
>>Orders and OrderDetails tables.
>> ds.Relations.Ad d
>>("Orders_Orde rDetails", ds.Tables["Orders"].Columns
>>["OrderID"], ds.Tables["OrderDetai ls"].Columns
>>["OrderID"]);
>>
>> //Bind the Authors table to the
>>parent Repeater control, and call DataBind.
>> parentRepeater. DataSource =
>>ds.Tables["Customers"];
>> Page.DataBind() ;
>>
>> //Close the connection.
>> cnn.Close();
>> }
>>
>> private void Page_Init(objec t sender,
>>EventArgs e)
>> {
>> InitializeCompo nent();
>> }
>>
>> private void InitializeCompo nent()
>> {
>> this.Load += new
>>System.EventH andler(this.Pag e_Load);
>> }
>> }
>>}
>>
>></code>
>>.
>>[/color]
>.
>[/color]