Skip to main content

Posts

Showing posts from July, 2015

Building a Database Driven Hierarchical Menu using ASP.NET 2.0

Introduction This tutorial will show you how to store hierarchical menu data in a single database table and how to retrieve and transform that data for display in Microsoft's Menu. Each step is explained and illustrated so that you can quickly extrapolate from this article to build your web application's menu. Note: This tutorial requires Visual Studio 2005 and SQL Server. Step 1 - Create and Fill a Database Self Join Table Our menu's table will use a self-join relationship which is the simplest method of storing hierarchical data. Child rows will use ParentID to establish a relationship with the MenuID of a parent row as shown below. Figure 1 - Table Overview   Let us start by creating a database called MenuDb and a Table called Menu.  This can be done by running the following script from Microsoft's Query Analyzer. Listing 1 - Database Script CREATE   DATABASE  MenuDb GO USE  MenuDb GO CREATE   TABLE  [Menu] (       [MenuID] 

ASP.NET TreeView Control

ASP.NET TreeView Control   TreeView The ASP.NET TreeView control is a powerful server-control for rendering TreeView UI, as shown in the figure below. It supports a variety of programming models, from statically-defined trees, to dynamically constructed trees, to databound trees. The TreeView's rendering is fully customizable, allowing for a wide-range of look-and-feels for the control. The TreeView supports both postback-style events and simple hyperlink navigation, as well as a unique event handling model that allows data to be retrieved directly from a client without requiring a server postback. It also supports rendering on a variety of browsers, and can take advantage of up-level capabilities, such as client-script on later desktop browser versions. The statically-defined tree is the simplest form of the TreeView, demonstrated below. Note that the persistence format for the TreeView intuitively resembles the hierarchical structure of the final