Examples of multilayer repeater,datagrid,datalist nesting

Source: Internet
Author: User
Tags integer
datagrid| sample
Often on the csdn to see a netizen asked how to achieve repeater,datalist, the datagrid nesting problem, the following gives a 3-layer nested example, can be nested indefinitely

<asp:repeater id= "Rpt_catalog" onitemdatabound= "Rpt_catalog_onitemdatabound" runat= "Server" >
<ITEMTEMPLATE> top floor repeater,index:<% #Container .dataitem%><br>
<asp:repeater id= "Rpt_board" onitemdatabound= "Rpt_board_onitemdatabound" runat= "Server" >
<ITEMTEMPLATE> 2nd Floor repeater,index:<% #Container .dataitem%><br>
<asp:repeater id= "Rpt_boardmaster" runat= "Server" >
<ITEMTEMPLATE> 3rd floor repeater,index:<% #Container .dataitem%><br>
</ITEMTEMPLATE>
</ASP:REPEATER>
</ITEMTEMPLATE>
</ASP:REPEATER>
</ITEMTEMPLATE>
</ASP:REPEATER>



Private Intfirst as Integer
Private Intsecond as Integer

Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
' Put user code to initialize the page
Dim Al as New ArrayList
Al. ADD (0)
Al. ADD (1)
Rpt_catalog. DataSource = Al
Rpt_catalog. DataBind ()
End Sub

Sub Rpt_catalog_onitemdatabound (ByVal sender as Object, ByVal e as RepeaterItemEventArgs)
Dim rpt as Repeater
rpt = E.item.findcontrol ("Rpt_board")
Intfirst = E.item.itemindex

Dim Al as New ArrayList
Al. ADD (Intfirst & ". 0")
Al. ADD (Intfirst & ". 1")
Rpt. DataSource = Al
Rpt. DataBind ()
End Sub

Sub Rpt_board_onitemdatabound (ByVal sender as Object, ByVal e as RepeaterItemEventArgs)
Dim rpt as Repeater
rpt = E.item.findcontrol ("Rpt_boardmaster")
Intsecond = E.item.itemindex
Dim Al as New ArrayList
Al. ADD (Intfirst & "." & Intsecond & ". 0")
Al. ADD (Intfirst & "." & Intsecond & ". 1")
Rpt. DataSource = Al
Rpt. DataBind ()
End Sub



The code has been tested, but please optimize it yourself


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.