Repeater displays the Master/Slave table structure

Source: Internet
Author: User

<% @ 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> untitled faces </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
'Create a connection and dataadapter for the authors table
Dim cnnstring as string = configurationmanager. connectionstrings ("CNN"). connectionstring
Dim CNN as new sqlconnection (cnnstring)
Dim cmd1 as new sqldataadapter ("select * From c_menuheader", CNN)

'create a filled dataset.
dim ds as new dataset ()
limit 1.fill (DS, "menuheader")
'sqlhelper. excutereadapdater ("select * from authors", commandtype. text, nothing)
'create a dataadapter for the titles table
dim cmd2 as new sqldataadapter ("select * From c_menuleft", CNN)
limit 2.fill (DS, "menuleft")

'Create the relationship between the authors table and the titles table.
DS. relations. add ("myrelation", DS. tables ("menuheader "). columns ("ID"), DS. tables ("menuleft "). columns ("PID "))

'Bind authors to parent Repeater
Parentrepeater. datasource = Ds. Tables ("menuheader ")
Page. databind ()

CNN. Close ()
CNN. Dispose ()
End sub

End Class
End namespace

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.