473,809 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populating the Menu - Navigation Control

MMA
How do I populate the menu control in 2.0 from a database. I know this can be
done with the Tree Control. Any code snippets? Thanks in advance.
Sep 20 '06 #1
2 1631
Just check the following snippet of code and let me know whether this is
usefule to you

private void PopulateMenu()
{
DataSet ds = GetDataSetFromD atabase();
Menu menu = new Menu();

foreach (DataRow parentItem in ds.Tables["Categories "].Rows)
{
MenuItem categoryItem = new MenuItem((strin g)parentItem["CategoryNa me"]);
menu.Items.Add( categoryItem);

foreach (DataRow childItem in parentItem.GetC hildRows("Child ren"))
{
MenuItem childrenItem = new MenuItem((strin g)childItem["ProductNam e"]);
categoryItem.Ch ildItems.Add(ch ildrenItem);
}
}
}

private DataSet GetDataFromData base()
{
SqlConnection myConnection = new SqlConnection(G etConnectionStr ing());
SqlDataAdapter adCat = new SqlDataAdapter( "SELECT * FROM Categories",
myConnection);
SqlDataAdapter adProd = new SqlDataAdapter( "SELECT * FROM Products",
myConnection);

DataSet ds = new DataSet();
adCat.Fill(ds, "Categories ");
adProd.Fill(ds, "Products") ;
ds.Relations.Ad d("Children",
ds.Tables["Categories "].Columns["CategoryID "],
ds.Tables["Products"].Columns["CategoryID "]);
return ds;
}
--
Thanks & Regards,
Sundar Narasimman
Technology Specialist

"MMA" wrote:
How do I populate the menu control in 2.0 from a database. I know this can be
done with the Tree Control. Any code snippets? Thanks in advance.

Sep 21 '06 #2
on this page is an example of another way of progrmmatically populating
a Menu control, without using relations

http://authors.aspalliance.com/aspxt...vigateUrl.aspx

Sep 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1629
by: Sisnaz | last post by:
I'm working with 2005 Beta 2 and I'm sure this is a trivial question but for the life of me I can't figure out. I placed a menu navigation componet on my master page and defined the navigation url for each menu item. I then created a new page and selected my master page. The menu control has a booled "Selected" property. As long as I don't set a navigation url, the menu item selected is set to true and highlighted. If I specify a...
0
1336
by: Andrew Polo | last post by:
Dear Sirs, I'm using Navigation Menu control on one of my Web Pages (.NET Framework 2.0). Everything is fine as far as I'm not using it within Master Page. If I make my page as a context of Master Page any Themes can't be applied to Navigation Menu. It looks right in design time, but losing Theme in runtime. Everything else is fine (according to Themes). Is there Menu control bug or my application is buggy? From...
9
1397
by: Jay | last post by:
I have an asp menu control with menu items navigateUrl set to come back to the same aspx page but with different values in a url token. this works, but it is causing all my asp controls to loose their values. Why is this happening? I thought I was "posting back" and my web controls with viewState=true should retain their values? Is this not the way to go about an aspx page coming back to itself? -- Jay
11
1724
by: Rickie | last post by:
Dear fellow software engineers, Is the web menu in asp 2.0 essentielle a useless control ? How many people( including msdn itself) are using server menu controls? Its a menu which always postback to server, which cant be caught on the event of a menuitem. Wouldnt we rather use other ways of making menus which are essentially clientsite ? With its postback its certainly not high on usebility. Then we have to use ajax or javascript...
3
2116
by: John | last post by:
Hi there, I was reading an article (http://avenuea-razorfish.com/articles/TheAll-MenuNavigation_Turbek.pdf) on 'all-menu navigation' and I'd like to try and implement this in my site. Can anyone recommend how to get started? Is there an Ajax control available for this or would more a basic javascript work just as well. I'm assuming I just need a div element that is shown on a mouse over, but I'm not sure how to go about aligning all...
9
6563
by: =?Utf-8?B?ZHBvbXQ=?= | last post by:
Hello, I have a problem with the ASP.NET menu when rendered in IE7: If the menu is inside a div with style="position:fixed;top:3em;", all the submenus also have the top:3em. Is this an IE7 issue (works fine in Firefox)? How can I achieve that the submenus have no top offset? Test code:
1
7714
by: Fabx | last post by:
Hallo, sorry for my english. I want to build a navigation menu with the repeat control, the items of menu are in a table of database. All items of the menu have class="MenuLink", but the item of the menu of the page that I am visiting would to different style, as an example class= "MenuLinkPage".
0
1315
by: RJN | last post by:
Hi I'm using the asp:Menu control in the sharepoint master page for displaying the site navigation. The site navigations are getting displayed. On clicking one of the menu items in the navigation, I want to change the style of the selected menu item so that it stands out as selected. Can anyone help me on this? I've tried using selecteditemstyle, but it didn't work. Thanks
3
1988
by: =?Utf-8?B?VG9tIFc=?= | last post by:
When I mouse over a Menu Control based navigation area the drop-down selection list appears instantaneously. Is there a way to make it less sensitive, so that it delays (even a fraction of a second would help) before dropping down the menu?
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10633
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.