我需要定义什么是孩子:
我需要写类似的东西var parent = categoryID == ParentCategoryID = 0
这是我的 ASCX 控件:
protected void Page_Load(object sender, EventArgs e)
{
categoriesBLL categoriesLogic2 = new categoriesBLL();
rptCategories.DataSource = categoriesLogic2.GetCategories();
rptCategories.DataBind();
}
我正在显示查询中的值,如下所示:
<ul class="categories">
<li>Computers</li>
<li>Hardware</li>
<li>Software</li>
</ul>
如您所见,硬件和软件应该是子类别,但它们与另一个 LI 显示在同一个 UL 块中。
我的数据集如下所示:
我有一个查询,它将在这里确定子类别:
SELECT c1.CategoryID, c2.ParentCategoryID,
c1.Name, c2.Name AS ParentName,
c1.Published, c1.Deleted, c1.PictureID
FROM Nop_Category AS c1 INNER JOIN
Nop_Category AS c2 ON c1.ParentCategoryID = c2.CategoryID
WHERE (c1.Deleted = 0)
AND (c1.Published = 1)
AND (c1.ParentCategoryID = @ParentCategoryID)
但是如何将类别的值传递到我的数据集中以返回结果?然后我需要创建一个新的 ul li:
<ul class="sub-category">
<li>Hardware</li>
<li>Software</li>
</ul>