views:

143

answers:

1

*I work on C#.*I want to develop asp.net application which contains menu but menu items should be generated from database. My intension is that Administrator can change menu items by working only on database, no need to change front end any how.

**

For example: Web page contains Menu as 
   1. Home
   2. About Us
   3. Contact Us

**

  So if Administrator wants can change  About Us menu to Our Clients menu, so administrator only need to modify in database don't touch front end any how.

  Any small help also appreciated.
  Thanks in advance.

Bellow is My SQL script :

USE [Northwind]
GO
/****** Object:  Table [dbo].[Security_Module_Menu]    Script Date: 08/05/2010 12:56:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Security_Module_Menu](
    [Menu_ID] [int] NOT NULL,
    [ParentID] [int] NULL,
    [Menu_Name] [nvarchar](500) NULL,
    [Menu_Description] [nvarchar](500) NULL,
    [Menu_Type] [tinyint] NULL,
    [Tree_Level] [tinyint] NULL,
    [Target_URL] [nvarchar](200) NULL,
    [Image_URL] [nvarchar](200) NULL,
    [ToolTips] [nvarchar](50) NULL,
    [Has_Charge] [bit] NULL,
    [Is_Active] [bit] NULL,
    [Active_Date] [smalldatetime] NULL,
    [Record_Status] [tinyint] NULL,
    [Record_Action_Type] [tinyint] NULL,
 CONSTRAINT [PK_Security_Module_Menu] PRIMARY KEY CLUSTERED 
(
    [Menu_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (1, 0, N'Form', N'Form', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (2, 0, N'Home', N'Home', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (3, 0, N'About', N'About', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (4, 1, N'Background', N'Background', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (5, 1, N'Detail', N'Detail', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (6, 3, N'FAQ', N'FAQ', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (7, 3, N'Forum', N'Forum', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (8, 3, N'ContactUs', N'ContactUs', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (9, 2, N'Report_User', N'Report_User', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (10, 2, N'Report_Login', N'Report_Login', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (11, 5, N'Admin_Detail', N'Admin_Detail', 1, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[Security_Module_Menu] ([Menu_ID], [ParentID], [Menu_Name], [Menu_Description], [Menu_Type], [Tree_Level], [Target_URL], [Image_URL], [ToolTips], [Has_Charge], [Is_Active], [Active_Date], [Record_Status], [Record_Action_Type]) VALUES (12, 5, N'User_Detail', N'User_Detail', 1, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)


Menu_Type=1=Form
Menu_Type=2=Report

ParentID=0=MainMenuItem

Tree_Level=1=MainMenuItem.
Tree_Level=2=SubMenuItem.
Tree_Level=3=Sub-SubMenuItem.

on server side ,AspxMenu how to bind with XML file .Actually i need 1)Create XML file using the Linq. 2)Then i need to bind this file with AspxMenu.

Using the Linq i want to create .xml file like bellow:

 XElement xml = new XElement("MyMenu",
                  from c in db.Security_Module_Menus
                  where (c.ParentID == 0)
                  orderby c.Menu_ID
                  select new XElement("Item",
                            new XAttribute("Text", c.Menu_Name), new XAttribute("NavigateUrl",c.Target_URL)


                            )
                  );
**Fill AspxMenu like bellow:**
            XmlDataSource1.DataFile = @"C:\contacts.xml";
        XmlDataSource1.XPath = "MyMenu/Item";

I need help to create XML file.Help me to create Xml file on basis of bellow criteria

    Menu_Type=1=Form
    Menu_Type=2=Report

    ParentID=0=MainMenuItem

    Tree_Level=1=MainMenuItem.
    Tree_Level=2=SubMenuItem.
    Tree_Level=3=Sub-SubMenuItem.
A: 

Hi,

By design, the ASPxMenu supports binding only to hierarchical data sources (those that implement the IHierarchicalDataSource interface - e.g. XmlDataSource, SiteMapDataSource) through its DataSourceID and DataSource properties.

If you need to bind an ASPxMenu control to a data table, some extra coding is required.

We've posted a tutorial illustrating how our ASPxMenu control can be created dynamically based on database information: http://www.devexpress.com/Support/Center/e/E49.aspx

This tutorial is a simplified version of a project attached to the following question issue: http://www.devexpress.com/Support/Center/p/DQ42250.aspx

DevExpress Team
For my menu ,Help me to create Xml file
shamim