Hi all,
Here is my code
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<html>
<head>
<meta name="GENERATOR" Content="ASP Express 2.1">
<title>Nested DataLists</title>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
Dim strConn as string =
"server=localhost;uid=sa;pwd=server;database=Northwind"
Dim MySQL as string = "Select CategoryID, CategoryName from
Categories"
Dim MyConn as New SQLConnection(strConn)
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,MyConn)
Cmd.Fill(ds,"Categories")
Dim cmd2 As SqlDataAdapter = New SqlDataAdapter("select * from
Products", MyConn)
cmd2.Fill(ds, "Products")
ds.Relations.Add("myrelation",
ds.Tables("Categories").Columns("CategoryID"),
ds.Tables("Products").Columns("CategoryID"))
dlCategories.Datasource=ds.Tables("Categories").DefaultView
DataBind()
End Sub
Function doFormat(sItem as Decimal)
Dim s as String
s=String.Format("{0:c}", sItem)
doFormat=s
End function
</script>
</head>
<body>
<asp:DataList runat="server"
Id="dlCategories"
GridLines="Both"
Bordercolor="black"
cellpadding="3"
cellspacing="0"
Headerstyle-BackColor="#DDDDDD"
Headerstyle-Forecolor="#777777"
Headerstyle-Font-Name="Arial"
Headerstyle-Font-Size="14"
Headerstyle-Font-Bold="true"
Font-Name="Arial"
Font-Bold="true"
Font-Italic="true"
Font-Size="11"
ForeColor="Red"
RepeatColumns="1">
<HeaderTemplate>
Categories & Products
</HeaderTemplate>
<ItemTemplate><%# Container.DataItem("CategoryName")%>
<br>
<asp:DataList runat="server"
Id="ChildDataList"
GridLines="None"
Bordercolor="black"
cellpadding="3"
cellspacing="0"
Headerstyle-BackColor="#8080C0"
Headerstyle-Font-Name="Arial"
Headerstyle-Font-Size="8"
Font-Name="Arial"
Font-Size="8"
datasource='<%#
Container.DataItem.Row.GetChildRows("myrelation") %>'
RepeatColumns="3">
<ItemTemplate>
<%
for (int i=0;i<2;i++) { %>
<%# Container.DataItem("ProductName") %>
} %>
- <%#
doFormat(Container.DataItem("UnitPrice")) %>
</ItemTemplate>
</ASP:DataList>
</ItemTemplate>
</ASP:DataList>
</body>
</html>
And my uutput is here
Categories & Products
Beverages
Chai - $18.00
Steeleye Stout - $18.00
Laughing Lumberjack Lager - $14.00
Chang - $19.00
Côte de Blaye - $263.50
Outback Lager - $15.00
Guaraná Fantástica - $4.50
Chartreuse verte - $18.00
Rhönbräu Klosterbier - $7.75
Sasquatch Ale - $14.00
Ipoh Coffee - $46.00
Lakkalikööri - $18.00
Condiments
Aniseed Syrup - $10.00
Northwoods Cranberry Sauce - $40.00
Vegie-spread - $43.90
Chef Anton's Cajun Seasoning - $22.00
Genen Shouyu - $15.50
Louisiana Fiery Hot Pepper Sauce - $21.05
Chef Anton's Gumbo Mix - $21.35
Gula Malacca - $19.45
Louisiana Hot Spiced Okra - $17.00
Grandma's Boysenberry Spread - $25.00
Sirop d'érable - $28.50
Original Frankfurter grüne Soße - $13.00
Confections
Pavlova - $17.45
Gumbär Gummibärchen - $31.23
Maxilaku - $20.00
Teatime Chocolate Biscuits - $9.20
Schoggi Schokolade - $43.90
Valkoinen suklaa - $16.25
Sir Rodney's Marmalade - $81.00
Zaanse koeken - $9.50
Tarte au sucre - $49.30
Sir Rodney's Scones - $10.00
Chocolade - $12.75
Scottish Longbreads - $12.50
NuNuCa Nuß-Nougat-Creme - $14.00
Dairy Products
Queso Cabrales - $21.00
Geitost - $2.50
Gudbrandsdalsost - $36.00
Queso Manchego La Pastora - $38.00
Raclette Courdavault - $55.00
Flotemysost - $21.50
Gorgonzola Telino - $12.50
Camembert Pierrot - $34.00
Mozzarella di Giovanni - $34.80
Mascarpone Fabioli - $32.00
Grains/Cereals
Gustaf's Knäckebröd - $21.00
Filo Mix - $7.00
Ravioli Angelo - $19.50
Tunnbröd - $9.00
Gnocchi di nonna Alice - $38.00
Wimmers gute Semmelknödel - $33.25
Singaporean Hokkien Fried Mee - $14.00
Meat/Poultry
Mishi Kobe Niku - $97.00
Thüringer Rostbratwurst - $123.79
Tourtière - $7.45
Alice Mutton - $39.00
Perth Pasties - $32.80
Pâté chinois - $24.00
Produce
Uncle Bob's Organic Dried Pears - $30.00
Rössle Sauerkraut - $45.60
Longlife Tofu - $10.00
Tofu - $23.25
Manjimup Dried Apples - $53.00
Seafood
Ikura - $31.00
Inlagd Sill - $19.00
Rogede sild - $9.50
Konbu - $6.00
Gravad lax - $26.00
Spegesild - $12.00
Carnarvon Tigers - $62.50
Boston Crab Meat - $18.40
Escargots de Bourgogne - $13.25
Nord-Ost Matjeshering - $25.89
Jack's New England Clam Chowder - $9.65
Röd Kaviar - $15.00
Now I want to display only two subcategories under each category.
Ex;
Beverages
Chai - $18.00
Steeleye Stout - $18.00
Condiments
Aniseed Syrup - $10.00
Northwoods Cranberry Sauce - $40.00
Confections
Pavlova - $17.45
Gumbär Gummibärchen - $31.23
Please tell me how to do it. Where should I make a change in this code.
---------------------------------
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/