如何在 ASP.NET MVC 中创建递归结构
我有一个类别表,其中包含三个字段:Id
、Title
和 ParentId
。我想在 cshtml 文件中创建表(树)的递归层次结构。我是 ASP.NET MVC 的新手,我不知道该怎么做,因为没有代码隐藏文件,我不知道应该从哪里开始。请注意,我在数据库中存储的是丛林,而不是树。换句话说,结果树可以有很多根。
I have a categories table which has three fields: Id
, Title
, and ParentId
. I'd like to create a recursive hierarchical structure of my table (a tree) in a cshtml file. I'm new to ASP.NET MVC and I don't know how to do that, because there is no code-behind file and I don't know from where should I start. Please note that I'm storing a jungle, not a tree in my database. In other words, the result tree can have many roots.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的是使用助手:
The easiest is using a helper: