473,756 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP 2.0 Menu Control Fed From Database

Rob
I want to feed the menu control from a database which is set up as
WebPageID, WebPageParent, URL where the WebPage Id is the primary key
and the WebpageParent is the foreign key. The menu will have multiple
nodes.

This example works in the treeview but I would really like to use the
horizontal orientation of the menu control. I understand that I may
lose the populate on command.

Does anyone know how to populate the menu control with multiple nodes
from a database?

Thank you in advance for the help.

<%@ Page Language="VB" %>
<%@ Import Namespace="Syst em.Data" %>
<%@ Import Namespace="Syst em.Data.SqlClie nt" %>
<script runat="server">

Const connectionStrin g As String = "Server=MySQLSe rver;
UID=MySQLUserID ; Password=MyPass word"

Sub TreeView1_TreeN odePopulate(sen der As Object, e As
TreeNodeEventAr gs)
Dim con As new SqlConnection(c onnectionString )
Dim cmd As New SqlCommand("SEL ECT [WebPageID],
[WebPageDescript ion], [WebPageURL], [WebPageParent] " & _
"FROM [MyDatabase].[dbo].[D_MyWebPages] " & _
"WHERE WebPageParent=@ WebPageParent", con)
cmd.Parameters. AddWithValue("@ WebPageParent", e.Node.Value)
con.Open()
Try
Dim dtr As SqlDataReader = cmd.ExecuteRead er()
While dtr.Read()
Dim newNode As new TreeNode()
newNode.Populat eOnDemand = True
newNode.Text = dtr("WebPageDes cription").ToSt ring()
newNode.Value = dtr("WebPageID" ).ToString()
e.Node.ChildNod es.Add(newNode)
End While
Finally
con.Close()
End Try
End Sub

</script>

<html>
<head runat="Server">
<title>Dynami c TreeView</title>
</head>
<body>
<form id="form1" runat="server">
<asp:TreeView
id="TreeView1"
ImageSet="Arrow s"
ShowLines="true "
ExpandDepth="1"
OnTreeNodePopul ate="TreeView1_ TreeNodePopulat e"
Runat="Server">
<Nodes>
<asp:TreeNode
Text="Messages"
Value="1"
PopulateOnDeman d="true" />
</Nodes>
</asp:TreeView>
<ASP:Table
Runat="Server"
GridLines="Hori zontal"
CellPadding="0"
CellSpacing="0"
Width="100%"
CssClass="Headi ngs"

<asp:TableRow Runat="Server" CssClass="Title ">
<ASP:TableCel l runat="Server" HorizontalAlign ="Left"
VerticalAlign=" Top">

</ASP:TableCell>
<ASP:TableCel l runat="Server" HorizontalAlign ="Left"
VerticalAlign=" Top">
Here is some Text that would sit in the left most column
</ASP:TableCell>
</asp:TableRow>
<asp:TableRow Runat="Server" CssClass="Headi ngs">
<ASP:TableCel l runat="Server" ColumnSpan="2">

</ASP:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>

Nov 19 '05 #1
0 1284

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

Similar topics

2
5870
by: PC User | last post by:
I'm creating a shortcut menu to popup over my richtext box. Its a form with a listbox of menu items with associated richtext activex (rtf) editing commands. I found a way to transfer a value from the popup menu to the form, but now I have one more step to take. The value being transferred is a public function from a module. I need to find a way to execute the function to edit the text in the richtext field. Download the test database from...
6
470
by: brian | last post by:
I am looking at purchasing or creating a dynamic navigational menu system that would be binded to SQL server 2000 data. The users id is stored in the SQL server and based on the id is what the navigational menu would show. I would perfer to gain the experieance of building it myself but theres not much documentation out there on that subject. If anyone has any please guide me to it.
2
2203
by: Tim::.. | last post by:
Hi can someone please tell me how I dynamically create a menu like the one shown below from a database. I want to create a loop that loops through all the records in a table and builds a table similar to the menu shown below I would be grateful if you could give me a ny assistance with this Thanks ...:: CODE ::. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa 'Put user code to...
4
2702
by: spx27 | last post by:
Does anyone know the best way to handle passing a dynamic menu generated from a login from one asp.net page to another. Would it be better to recreate the menu on each page? Save the menu as a string into a session variable upon login? Any other way to do this I may be missing? This menu is part of an intranet. The user logs in, checks SQL database for folder permissions, then scans web directories for all folders which match permissions...
6
3236
by: Sandy | last post by:
Hello - I have a book that illustrates pulling menu items from a Sql Server table into an ascx via a stored procedure. Is this something that is done in the real world? I do like the effect when viewing it in the source code, however, because it doesn't show the complete path to the file. (I'm talking about Internet Explorer click View, click source code.)
1
2376
by: JJ | last post by:
I'm trying to create the cut/paste/select all context menu on number of richtextboxes. On the contextmenu.popup handler, I want to find out what control is currently displaying the context menu. I thought I could use: Private Sub KL_ClipboardContMenu_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KL_ClipboardContMenu.Popup 'To find out which control is displaying the context menu: Try
1
4478
by: stinehelferw | last post by:
I need a right-click menu on a form list control with combobox controls. I used View->Toolbars->Customize to create a toolbar. I added ComboBox through commands tab. I set properties to Popup making it a shortcut menu. I have no problem linking it to the list control. The menu comes up when I right-click the list control.
2
1616
by: dorrit.Riemenschneider | last post by:
Hi, I develop a sharepoint webpart with ASP.Net 2.0 and therefore override CreateChildControls(). In CreateChildControls() I create dynamically a menu with items (and sub items) from a database. Let's say after the first loading I have 5 menu items. My problem: Every time the page is loaded (that means also if a menu item is clicked) the menu items are doubled (I have 10, 15, 20, ... menu items).
1
2379
by: Brad Isaacs | last post by:
want to know if you could please help me out in resolving an issue I am having regarding my Menu control. The ASP.NET Menu control requires extra work in order to access the database data, if you want to populate your Menu control with database data. I have added my control to my MasterPage and written some code to display the data from the dataset table. However, I cannot figure out how I am going to extract the LANGUAGE used by the...
0
9456
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
9275
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
10034
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
9872
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...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5142
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
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.