D
dplsr
Good morning!
I am trying to nest a datalist of subcategories inside a datalist of
categories. All from the same SQL 2000 Table. I get the error: "These
columns don't currently have unique values." I have tested both select
statements in the query analyzer and they work fine. Is it possible to do
this?
If Page.IsPostBack = False Then
Dim objConn As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim MySQL as string = "select distinct category from CMRC_products where
gencategory like 'kitchen' "
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,objConn)
Cmd.Fill(ds,"CMRC_products")
dim strcategory= ds.Tables(0).Rows(0)("category")
Dim cmd2 As SqlDataAdapter = New SqlDataAdapter("select distinct
subcategory from CMRC_products where gencategory like 'Kitchen' and category
like '"& strcategory &"' ", objConn)
cmd2.Fill(ds, "CMRC_products")
ds.Relations.Add("myrelation",
ds.Tables("CMRC_products").Columns("Category"),
ds.Tables("CMRC_products").Columns("subCategory"))
dlCategories.Datasource=ds.Tables("CMRC_products").DefaultView
DataBind()
end if
End Sub
<form id="Form1" method="post" runat="server">
<aspataList runat="server" Id="dlCategories"
RepeatColumns="1">
<HeaderTemplate>
Categories & SubCategories
</HeaderTemplate>
<ItemTemplate>
<a href="mfgcatsubcat.aspx?category=<%# DataBinder.Eval(Container.DataItem,
"category") %>"><%# DataBinder.Eval(Container.DataItem, "category")%></
<br>
<aspataList runat="server" Id="ChildDataList" datasource='<%#
Container.DataItem.Row.GetChildRows("myrelation") %>'>
<ItemTemplate>
<a href="prodisplay.asp?subcategory=<%#
DataBinder.Eval(Container.DataItem, "subcategory")
%>&category=<%#strcategory%>"><%# DataBinder.Eval(Container.DataItem,
"subcategory") %></a> </ItemTemplate>
</ASPataList>
</ItemTemplate>
</ASPataList>
</Form>
I am trying to nest a datalist of subcategories inside a datalist of
categories. All from the same SQL 2000 Table. I get the error: "These
columns don't currently have unique values." I have tested both select
statements in the query analyzer and they work fine. Is it possible to do
this?
If Page.IsPostBack = False Then
Dim objConn As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim MySQL as string = "select distinct category from CMRC_products where
gencategory like 'kitchen' "
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,objConn)
Cmd.Fill(ds,"CMRC_products")
dim strcategory= ds.Tables(0).Rows(0)("category")
Dim cmd2 As SqlDataAdapter = New SqlDataAdapter("select distinct
subcategory from CMRC_products where gencategory like 'Kitchen' and category
like '"& strcategory &"' ", objConn)
cmd2.Fill(ds, "CMRC_products")
ds.Relations.Add("myrelation",
ds.Tables("CMRC_products").Columns("Category"),
ds.Tables("CMRC_products").Columns("subCategory"))
dlCategories.Datasource=ds.Tables("CMRC_products").DefaultView
DataBind()
end if
End Sub
<form id="Form1" method="post" runat="server">
<aspataList runat="server" Id="dlCategories"
RepeatColumns="1">
<HeaderTemplate>
Categories & SubCategories
</HeaderTemplate>
<ItemTemplate>
<a href="mfgcatsubcat.aspx?category=<%# DataBinder.Eval(Container.DataItem,
"category") %>"><%# DataBinder.Eval(Container.DataItem, "category")%></
<br>
<aspataList runat="server" Id="ChildDataList" datasource='<%#
Container.DataItem.Row.GetChildRows("myrelation") %>'>
<ItemTemplate>
<a href="prodisplay.asp?subcategory=<%#
DataBinder.Eval(Container.DataItem, "subcategory")
%>&category=<%#strcategory%>"><%# DataBinder.Eval(Container.DataItem,
"subcategory") %></a> </ItemTemplate>
</ASPataList>
</ItemTemplate>
</ASPataList>
</Form>