The best practice to setup hierarchy data

I'm trying to figure out the best practice to setup hierarchy data that i take from a database into some contoller that would show the hierachy. Basicly this would look like a normal tree but when you press the items that are under "chapters" you get a link to another page.

I have these tables and this is the way they are connected

Period Courses Subjects Chapters

I select Period from a DropDownBox and then i want all the courses in that period to line up. Under each course would be the subject and under them are the chapers, typical hierarchy.

The tables are linked together with refrences to each other in linear way.

I have tried to use treeview to show this, but dont understand how to do it. I though i could use <ul><il> tags and do it at runtime. Reapeter or datalist, possible ?

Is it better to do this with databinding in XAML or in code ?

-------------Problems Reply------------

In my experience its best to to it with li and ul. You have more control of how everything is displayed. I got the query that gives me all the records and parent and depth. Then I loop throught this data and generated the list tags.

foreach (DataRow row in navigationTable.Rows) {

var currentDepth = int.Parse(row["depth"].ToString());

if (lastDepth < currentDepth)
else if (lastDepth > currentDepth)
while (lastDepth > currentDepth)
else if (lastDepth > -1)

output.AppendFormat("<li id=\"base\" class=\"class\">{3}<a>link</a>

lastDepth = currentDepth;

for (var i = 1; i <= numUl; i++)
} Views:0 Time:2010-06-09

Related post

  • Polling data from server - most effecient and practical way/setup 2011-06-28

    I've been reading a few posts on here regarding polling and even had a look at Pusher although i don't want to go down that route and need some advice in regards of making an efficent notification system. How do facebook, twitter and other websites d

  • Handling Hierarchy Data in Database 2009-02-25

    I'm curious to know what the best way (best practice) to handle hierarchies are in regards to database design. Here is a small example of how I usually handle them. Node Table NodeId int PRIMARY KEY NodeParentId int NULL DisplaySeq int NOT NULL Title

  • What is the best practice for implementing a data table with many inserts, deletes and reads? 2009-05-13

    I am creating a functionality where our wcf services logs all changes that are stored thru them and the changes need to be sent to other systems. After every service call with changes we store the changes in a table (the changes is serialized). Regul

  • SQL Server 2008 Hierarchy Data Type Performance? 2009-06-25

    How does SQL Server 2008's Hierarchy data type perform compared to using the hierarchy implementation described by Joe Celko here: I've used Celko's method in the past with great results - but

  • Reorder nodes in SQL Hierarchy data type 2009-08-16

    Using Hierarchy data type on SQL 2008. Nodes in my hierarchy go like this: value node 36 /8/1/ 38 /8/2/ 34 /8/3/ 40 /8/4/ 42 /8/5/ 44 /8/6/ 46 /8/7/ 48 /8/8/ I'd like to rearrange nodes so that /8/3/ and /8/1/ switch places. Any idea on how to do thi

  • NHibernate mapping for SQL Server 2008 Hierarchy Data Type 2009-09-24

    Just wondering what the best mapping pattern is for NHibernate (latest release) with SQL Server 2008 and the hierarchy data type. Thanks --------------Solutions------------- I don't have any experience with this new type in Sql Server 2008 but I susp

  • Best practice to store temporary data for a webapp 2009-12-28

    My newest project is able to generate documents with information from a database. So I copy the document template on demand to a temporary folder for a user and modify it. I do this because every template must be available during modification. Afterw

  • Class Hierarchy - Data design in an RPG game where classes overlap (VB.Net) 2010-08-19

    This is a followup to the question I asked here: I understand the answer in the post above, which is absolutely amazing, by the way. It's about implementing

  • What is a practical process for doing data transformation on a live system when hibernate + code generation is used? 2010-08-26

    I have an existing database defined via HBM.XML files (code and sql dml generated via Hibernate tools), and am looking for a practical way to perform data transformation on existing data. So supposed the following: The original table is defined with

  • Generate an algorithm in C# to take hierarchy data to generate this html 2011-03-28

    I have this html as a reference and I have a set of hierarchy data. The names of the nodes are hopefully helpful to understand where they fit in the chain here is the reference html (hardcoded) <ul id="tree1"> <li><input type="checkbox

  • Hierarchial data in silverlight datagrid 2011-06-24

    I am trying to create a Datagrid where the first column contains '+' sign and next columns contain the data. When the user clicks the '+' sign the data is taken from the current row and the corresponding hierarchial data from different table is displ

  • Best practices for creating a data model 2011-08-17

    For a current project I'm creating a data model. Are there any sources where I can find "best practices" for a good data model? Good means flexible, efficient, with good performance, style, ... Some example questions would be "naming of columns", "wh

  • What are the best practices to cache the data? 2012-01-26

    What are the best practices to cache the data in iOS apps connected to data source via web service? --------------Solutions------------- You should lookat NSCache

  • How to store hierarchial data and display it in a table 2012-02-19

    I want to store hierarchial data like: d1 -> { ns1 -> {ip1,ip2}, ns2 -> {ip3,ip4}, .... .... }, d2 -> { ns3 -> {ip3,ip5}, ns4 -> {ip6,ip9}, .... .... }, and so on..... I know I need to use references, but I am having hard time under

  • Setup test data with UIAutomation 2012-02-25

    Is it possible to setup test data when running UIAutomation tests for iOS? I've seen some post that suggests you have uiautomation go through the UI to create the test data, but that seems like a generally bad approach to me. Besides, my particular a

  • Hierarchy & data structure in Java (or XML to Object conversion: best practices) 2009-04-05

    The problem: Let's say there is an XML file that contains both the data and the hierarchy of certain elements of interest to the application: <root> <node title="lvl1Node"> <node title="lvl2Node"> <node title="lvl3Node"></n

  • What is the best way to setup hierarchy in sql server 2005? 2010-10-08

    I am trying to setup an hierarchial structure for company. I was using SQL Server 2008 and used hierarchy id to set it up. But now I need to move back to SQL Server 2005...and "just do it"... Anyways I thought of setting it up this simple way - Id |

  • Best Practice: Protecting Personally Identifiable Data in a ASP.NET / SQL Server 2008 Environment 2011-01-18

    Thanks to a SQL injection vulnerability found last week, some of my recommendations are being investigated at work. We recently re-did an application which stores personally identifiable information whose disclosure could lead to identity theft. Whil

  • MVC best practice question: producing XML data extracts from a model? 2011-03-28

    I'm using an MVC framework to develop an app that produces data extracts in XML format. An extract file is produced hourly using cron. I have a model called DataExtract that stores the date range for the extract. I also have a view containing the XML

Copyright (C), All Rights Reserved.

processed in 0.148 (s). 11 q(s)