Torna al Thread

aspx <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <b><%#DataBinder.Eval(Container.DataItem, "parent_id")%></b><br> <asp:Repeater ID="Repeater2" runat="server" datasource='<%# DirectCast(Container.DataItem,DataRowView).Row.GetChildRows("myrelation")%>'> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "categories_name")%> <br /> </ItemTemplate> </asp:Repeater> </ItemTemplate> </asp:Repeater> aspx.vb 'Create the connection and DataAdapter for the Authors table. Dim cnn As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\jaykay.net_29_Luglio\Visual Studio 2005\WebSites\jaykay_28_Luglio_2006\App_Data\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True") Dim cmd1 As New SqlClient.SqlDataAdapter("select * from categories", cnn) 'Create and fill the DataSet. Dim ds As New DataSet() cmd1.Fill(ds, "categories") 'Create a second DataAdapter for the Titles table. Dim cmd2 As New SqlClient.SqlDataAdapter("select * from categories_description", cnn) cmd2.Fill(ds, "categories_description") 'Create the relation bewtween the Authors and Titles tables. ds.Relations.Add("myrelation", ds.Tables("categories").Columns("categories_id"), ds.Tables("categories_description").Columns("categories_id")) 'Bind the Authors table to the parent Repeater control, and call DataBind. Repeater1.DataSource = ds.Tables("categories") Page.DataBind() 'Close the connection. cnn.Close() 'page.Controls(0).Controls(4).Controls(1).Controls(1).Controls(15).Controls(1)
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5