| 
				  dttable = DBcon.Excuteselect(strsql) ‘得到其下所有商品信息 
                End If 
            End If 
        Next 
        DataList1.DataSource = dttable.DefaultView 
        DataList1.DataKeyField = "shopid" 
        DataList1.DataBind() 
    End Sub 
  
    Protected Sub get_child(ByVal newtable As DataTable) 
        For Each drrow As DataRow In newtable.Rows 
            If drrow("havechild").ToString = "y" Then 
                Dim childtable As DataTable = table1.Clone() 
                For Each row As DataRow In table1.Rows 
                    If row("parentid").ToString = drrow("catalogid").ToString Then 
                        Dim newrow As DataRow = childtable.NewRow() 
                        newrow.ItemArray = row.ItemArray 
                        childtable.Rows.Add(newrow) 
                    End If 
                Next 
                get_child(childtable) 
            Else 
                strsql = "select catalogs.*,shop.* from shop inner join catalogs on shop.catalogid=catalogs.catalogid where shop.catalogid=" & drrow("catalogid") 
                If dttable.Rows.Count = 0 Then 
                    dttable = DBcon.Excuteselect(strsql) 
                Else 
                    Dim childtable As DataTable = DBcon.Excuteselect(strsql) 
                    For Each row As DataRow In childtable.Rows 
                        Dim newrow As DataRow = dttable.NewRow() 
                        newrow.ItemArray = row.ItemArray 
                        dttable.Rows.Add(newrow) 
                    Next 
                End If 
            End If 
        Next 
    End Sub 
End class 
5  结语 
针对电子商务网站建设中着重介绍了商品多极分类的实现,这种方法灵活性较大,适用性较强,所有源代码均在xp+asp.net2.0环境下调试成功。本文的范例还可以扩展应用到其他管理信息系统之中,如:人事管理、部门设置。 			
				 |