これが私と一緒に働くコードです:
SQL ストアド プロシージャの場合
CREATE PROCEDURE [dbo].[GetBrandProductsCats]
@iLanguageID int,
@iBrandID int
As
Begin
select C.CategoryID,C.ParentID, BrandID = @iBrandID, C.Image, CD.Title, CD.Summary from Categories C
Join CategoryData CD on C.CategoryID = CD.CategoryID
Join BrandsCategories BC on BC.CategoryID = C.CategoryID and BC.BrandID = @iBrandID
Where C.ParentID=0 and C.Status=1 and CD.LanguageID=@iLanguageID
End
GO
コードの場合:
製品の猫を取得するために保管された親 ID を使用し、その画像をサブ猫用の関数にしました。
<asp:Repeater id="rpCats" runat="server" >
<ItemTemplate>
<a href="categories.aspx?pid=<%# DataBinder.Eval(Container.DataItem, "ParentID") %>&brandid=<%# DataBinder.Eval(Container.DataItem, "BrandID") %>"><%# DataBinder.Eval(Container.DataItem, "Title") %></a>
<%# DataBinder.Eval(Container.DataItem, "Summary") %>
<asp:Repeater id="rpSubCats" runat="server" DataSource='<%# GetSubCats(CInt(DataBinder.Eval(Container.DataItem, "ParentID")))%>'>
<ItemTemplate >
<a href='products.aspx?pid=<%# DataBinder.Eval(Container.DataItem, "ParentID") %>&cid=<%# DataBinder.Eval(Container.DataItem, "CategoryID") %>&brandid=<%# DataBinder.Eval(Container.DataItem, "BrandID") %>'><%# DataBinder.Eval(Container.DataItem, "Title") %></a>
</ItemTemplate>
</asp:Repeater>
<div id="tblPic" runat="server">
<asp:Image id="imgThumb" runat="server" Borderwidth="0" Width="70px"></asp:Image>
</div>
<asp:TextBox id="txtImage" runat="server" Visible="False" Text='<%# DataBinder.Eval(Container.DataItem, "Image") %>'></asp:TextBox>
<asp:TextBox id="txtID" runat="server" Visible="False" Text='<%# DataBinder.Eval(Container.DataItem, "ParentID") %>'></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
ここに GetSubCats 関数があります
Public Function GetSubCats(ByVal intParentID As Integer) As DataView
If Request("brandid") <> "" Then
Dim objDB As New ProductsDB
Dim dsSubCats As New DataSet
objDB.daGetBrandProductsSubCats.SelectCommand.Parameters("@iParentID").Value = intParentID
objDB.daGetBrandProductsSubCats.SelectCommand.Parameters("@iLanguageID").Value = System.Configuration.ConfigurationManager.AppSettings("LanguageID")
objDB.daGetBrandProductsSubCats.SelectCommand.Parameters("@iBrandID").Value = Request("brandid")
objDB.daGetBrandProductsSubCats.Fill(dsSubCats)
Dim dvSubCats As DataView = dsSubCats.Tables(0).DefaultView
GetSubCats = dvSubCats
End If
End Function
ありがとうございました。