Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. display menu items based on database table values

display menu items based on database table values

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Punit Belani
    wrote on last edited by
    #1

    i want to display a menu on user home page. The menu items will be added / updated by admin(client) in admin section after I deploy the project to him. He would be shown a page on which he would add the various menu items. These would be stored into databse and then displayed on menu at home page. Can someone help me with the code for implementing this?

    A Z 2 Replies Last reply
    0
    • P Punit Belani

      i want to display a menu on user home page. The menu items will be added / updated by admin(client) in admin section after I deploy the project to him. He would be shown a page on which he would add the various menu items. These would be stored into databse and then displayed on menu at home page. Can someone help me with the code for implementing this?

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Yes, you can do it very easily. You have use menu as dyanmic. Here is two complete example, Building a Database Driven Hierarchical Menu using ASP.NET 2.0[^] and Populating Menu Control in ASP.NET 2.0 - using different data sources[^] Hope this will help you :-D

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

      1 Reply Last reply
      0
      • P Punit Belani

        i want to display a menu on user home page. The menu items will be added / updated by admin(client) in admin section after I deploy the project to him. He would be shown a page on which he would add the various menu items. These would be stored into databse and then displayed on menu at home page. Can someone help me with the code for implementing this?

        Z Offline
        Z Offline
        Zafar A khan
        wrote on last edited by
        #3

        Create a table with fields MenuCaption,NavigateUrl etc the fields without navigateurl should be update able. then on home page retrieve all the fields and add it to menu as menuitem. Like this

        SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString);
        SqlDataAdapter da = new SqlDataAdapter("select * from mainMenu", con);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
        foreach (DataRow row in dt.Rows)
        {
        MenuItem itm = new MenuItem(row["MenuCaption"].ToString(), "value", "", row["NavigateUrl"].ToString());
        Menu1.Items.Add(itm);
        }
        }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups