sql server - Hierarchical Database Driven Menu in MVC -
I use the code below as an HTMLHelper that receives data from the database and displays a menu Gives the end to that. This is quite straightforward because you can see though, what will happen if you have a database table using the adjacent model of the hierarchy eg ID / ParentID, order ID. It's easy to see what's going on, but requiring recursion to get this data properly. Is C # recursive function acceptable? If such a person can help me? Expected output is similar to this ..
& lt; Ul & gt; & Lt; Li & gt; Item 1 & lt; Ul & gt; & Lt; Li & gt; SubItem1 & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; There is now a hierarchy datatype in SQL 2008, so I'm not sure that things will help it?
I also have to decide which items are run in the menu, to enable them to select a list of items that go to the menu and then select these items and select their status in the hierarchy. There will also be a way to do it
Am I asking too much, am I sure that this should be a normal scenario?
This is my HTMLHelper code if someone wants to use it ...
Static String Menu (HtmlHelper Assistant, int MenuCat) {string menuHTML = "& Lt; ul id = \ "menu \" & gt; "; Var route = helper VisualEntax Request TEXT Root data; String currentPageName = route.GetRequiredString ("id"); DB DB = DB CreteDBee (); // var results = p to db.WebPages where p.CategoryID ==9p; Var results = p; db.WebPages choose p; Foreign currency (different items in result) {if (item.Name == currentPageName) {menu html + "\ n \ tNext, place an ordering logic on your app, you do not need DB to do this because it increases the cycle and (from what I have read) is not very efficient. This is a simple reference logic in which With self-referencing involvement, Linq is perfect for that.
Leave it on jQuery, ADN is good for you to go without code-coding HTML code :)
Comments
Post a Comment