链接列表框子类别

发布于 2024-09-01 11:35:39 字数 363 浏览 5 评论 0原文

我使用 aspx 已经有几个月了,现在我正在开发一个购物车网站。为了让员工在数据库上上传产品,每个产品都需要链接到一个类别和子类别,以及子子类别,等等。有时子子类别最多可达 5 个。例如 Electronics-TV-LCD-Samsung-40 英寸。

首先,我想确定的是 SQL 表是否具有适当的结构。我有 3 列 ID、描述、Parent_Id。 Parent Id=0 的类别用于顶级类别。这是最好的方法吗?

然后我想使用 ListBox 控件选择主类别,一旦选择它,就用它的子项填充第二个列表框,依此类推。每次发生更改事件时都需要查询 SQL DB 吗?我听说过 linq 但尚未使用,您对此有何建议。如果您看过示例以更好地理解它,我们将不胜感激。

谢谢

I have few monhts working with aspx, and now I'm developing a shopping cart website. For the employee to upload the products on the DB, every product needs to be linked to a category and sub category, and sub-sub category, and so on. Sometimes the sub-sub categories are up to 5. For example Electronics-TV-LCD-Samsung-40 inches.

First, What I would like to identify is if the SQL table has the apporpiate structure. I have 3 columns Id, Description, Parent_Id. Categories with Parent Id=0 is used for the top ones. Is this the best way to do it?

Then I want to use the ListBox control to select main Categories, and once it is selected, filled a second listbox with its childs and so on. Do I need to query SQL DB everytime the change event happens? I heard about linq but have not used yet, What would be your suggestion to do this. If you have seen a sample to understand it better will be appreciated.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伤痕我心 2024-09-08 11:35:39

我想说类别表结构是合理的。有多种方法可以实现该接口。您可以在不调用数据库的情况下填充子列表框,但是您必须在每次页面刷新时检索整个层次结构并将它们存储在 javascript 数组或类似的中,然后使用 javascript 填充子列表框,这可能会产生很多额外的费用数据是一个完整的类别层次结构。您还可以在列表框中设置 autopostback=true 属性,每次选择更改时它都会回发到服务器,但这有点笨拙。中间立场是使用 ajax。最简单的方法是使用更新面板,只需将其设计为回发方式并将列表框包装在更新面板中即可。最有效的方法是编写一个 Web 服务来返回类别列表,并使用脚本管理器控件将其连接起来。然后,您可以使用 javascript 调用它,并使用 Web 服务返回的数据填充您的列表框。

I would say that the category table structure is sensible. There are a number of ways to implement the interface. You could populate the child listboxes without a call to the database, but you would have to retrieve the entire hierarchy with every page refresh and store them in javascript arays or similar and then populate the child listboxes using javascript, this might be a lot of extra data if is a comples category hierarchy. You could also set the autopostback=true propertyon the listbox and it will postback to the server every time the selection changes,this is a bit clunky though. A middle ground would be to use ajax. The easiest way to do this is to use update panels, just design it the postback way and wrap your listboxes in update panels. The most eficient way would be to write a web service to return a list of categories and wire it up using a scriptmanager control. You can then call it using javascript and poulate your listboxes with the data returne by the web service.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文