Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Multi Level Repeater Nesting

Avatar of JimDestruct
JimDestructFlag for United Kingdom of Great Britain and Northern Ireland asked on
ASP.NET
2 Comments1 Solution1475 ViewsLast Modified:
I have an issue whereby I want to be able to create nested repeaters (as many as I want). The problem I am having at the moment is that I can create a relationship between two fine but when it comes to creating a relationship to another table (a third) I get the following error:

System.ArgumentException: These columns don't currently have unique values.

The error relates to my level2and3 relation. What I need to happen is this:

1) The parent (level1) repeater lists its information
2) The level2 table displays its data which is related to the level 1 id
3) The level3 table displays its data which is related to the level 2 id

so data is passed down:

Level1  --->  level 2 (related by level1.id->level2.level1_id)  --->  level3 (related by level2.id->level3.level2_id)

I can't work out how to do this at all. Any help would be greatly appreciated.

I am working in VB.NET

Dim cmd1 As New SqlDataAdapter("select * from products_level1 WHERE (id = 1)", ConnectionString())
 
Dim ds As New DataSet()
cmd1.Fill(ds, "products_level1")
 
Dim cmd2 As New SqlDataAdapter("select products_level2.title, products_level1.id, products_level2.level1_id from products_level2, products_level1 where (products_level2.level1_id = products_level1.id)", ConnectionString())
cmd2.Fill(ds, "products_level2")
 
Dim cmd3 As New SqlDataAdapter("select products_level3.title, products_level2.id, products_level3.level2_id from products_level3, products_level2 where (products_level3.level2_id = products_level2.id)", ConnectionString())
cmd3.Fill(ds, "products_level3")
 
ds.Relations.Add("level1and2", ds.Tables("products_level1").Columns("id"), ds.Tables("products_level2").Columns("level1_id"))
 
ds.Relations.Add("level2and3", ds.Tables("products_level3").Columns("level2_id"), ds.Tables("products_level2").Columns("id"))
 
Level1.DataSource = ds.Tables("products_level1")
Page.DataBind()
 
 
 
 
 
 
 
<%@ Import Namespace="System.Data" %>
 
<asp:Repeater ID="Level1" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "title")%>
 
<asp:Repeater ID="Level2" 
DataSource='<%# Ctype(Container.Dataitem,DataRowView).Row.GetChildRows("level1and2")%>' runat="server">
<ItemTemplate>
 
<%#DataBinder.Eval(Container.DataItem, "(title)")%>
 
 
<asp:Repeater ID="Level3" 
DataSource='<%# Ctype(Container.Dataitem,DataRowView).Row.GetChildRows("level2and3")%>' runat="server">
<ItemTemplate>
 
<%#DataBinder.Eval(Container.DataItem, "(title)")%>
 
</ItemTemplate>
</asp:Repeater>
 
 
</ItemTemplate>
</asp:Repeater>
            
</ItemTemplate>
</asp:Repeater>
 
 
 
 
</ItemTemplate>
</asp:Repeater>
ASKER CERTIFIED SOLUTION
Avatar of JimDestruct
JimDestructFlag of United Kingdom of Great Britain and Northern Ireland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers