zoukankan      html  css  js  c++  java
  • repeater 嵌套

    代码
     Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load
            
    Dim dt As DataTable = New DataTable
            
    Dim sqlCom As SQLCommon = New SQLCommon
            dt 
    = sqlCom.ExecuteQuery("SELECT * FROM tblProductCategory")
            
    Me.rptCategory.DataSource = dt
            
    Me.rptCategory.DataBind()

        
    End Sub

        
    Protected Sub rptCategory_ItemDataBound(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptCategory.ItemDataBound
            
    Dim sqlCom As SQLCommon = New SQLCommon
            
    Dim dt As DataTable = New DataTable

            
    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                
    Dim rep As System.Web.UI.WebControls.Repeater = e.Item.FindControl("rptSubCategory")
                
    Dim rowv As DataRowView = CType(e.Item.DataItem, DataRowView)
                
    Dim strKey As String = CType(rowv("productCategoryName"), String)
                dt 
    = sqlCom.ExecuteQuery("SELECT * FROM tblProductSubCategory WHERE productCategoryName='" & strKey & "'")
                rep.DataSource 
    = dt
                rep.DataBind()



            
    End If
        
    End Sub
    代码
     <form id="form1" runat="server">
            
    <asp:Repeater ID="rptCategory" runat="server">
                
    <ItemTemplate>
                    
    <%#Eval("productCategoryName")%>   <br />
                    
    <asp:Repeater ID="rptSubCategory" runat ="server" >
                    
    <ItemTemplate >
                    
    <div style ="color :Red;"><%#Eval("productSubCategoryName")%> </div>
                    
    </ItemTemplate>
                    
    </asp:Repeater>                           
                
    </ItemTemplate>
            
    </asp:Repeater>
        
    </form>
  • 相关阅读:
    QGroundControl编译出错记录
    【Luogu】【关卡2-5】字符串处理(2017年10月)
    【Luogu】【关卡2-4】排序Ex(2017年10月)
    【Luogu】【关卡2-3】排序(2017年10月) 【AK】
    【Luogu】【关卡2-2】交叉模拟(2017年10月)
    【Luogu】【关卡2-1】简单的模拟(2017年10月)
    【基础】图论基础 2017/04/20
    【LeetCode】BFS || DFS [2017.04.10--2017.04.17]
    【LeetCode】排序
    【LeetCode】贪心
  • 原文地址:https://www.cnblogs.com/services/p/1703374.html
Copyright © 2011-2022 走看看