<%@ Page Language="VB" AutoEventWireup="false" CodeFile="MenuALL.aspx.vb" Inherits="eMeng.MenuALL" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>未命名頁面</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:repeater id="parentRepeater" runat="server">
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem,"span") %>
<asp:repeater id="childRepeater" runat="server" datasource='<%# Container.DataItem("myrelation") %>'>
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "menu")%>
</itemtemplate>
</asp:repeater>
</itemtemplate>
</asp:repeater>
</div>
</form>
</body>
</html>
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace eMeng
Public Class MenuALL
Inherits System.Web.UI.Page
'Dim parentRepeater As System.Web.UI.WebControls.Repeater
Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
'为Authors表创建 Connection 和 DataAdapter
Dim cnnString As String = ConfigurationManager.ConnectionStrings("cnn").ConnectionString
Dim cnn As New SqlConnection(cnnString)
Dim cmd1 As New SqlDataAdapter("select * from c_MenuHeader", cnn)
'创建填充 DataSet.
Dim ds As New DataSet()
cmd1.Fill(ds, "MenuHeader")
'SqlHelper.ExcuteReadApdater("select * from authors", CommandType.Text, Nothing)
' 为Titles表创建 DataAdapter
Dim cmd2 As New SqlDataAdapter("select * from c_MenuLeft", cnn)
cmd2.Fill(ds, "MenuLeft")
' 创建 Authors 表和 Titles 表之间的关系.
ds.Relations.Add("myrelation", ds.Tables("MenuHeader").Columns("id"), ds.Tables("MenuLeft").Columns("pid"))
' 绑定Authors到父Repeater
parentRepeater.DataSource = ds.Tables("MenuHeader")
Page.DataBind()
cnn.Close()
cnn.Dispose()
End Sub
End Class
End Namespace