473,395 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Database Driven Menus

I am trying to write a data driven menu. I am still a beginner so am
asking for advice.

My current method is to load all of the result into a html style
string using the following code:
############################
Public Function GetMenuList() As String
Do While myReader.Read()
strResult += Environment.NewLine
strResult += "<table class='CatMenu' ><tr><td
class='MenuCategory'>" & myReader("Category") & "</td></tr>" &
Environment.NewLine
strResult += GetSubCategories(CInt((myReader("CategoryID"))))
& "</table>" & Environment.NewLine
strResult += "<br />"
Loop
end function

Public Function GetSubCategories(ByVal CategoryID As Integer) As
String
load reader code etc..
Do While myReader.Read()
strResult += "<tr><td class='MenuSubCategory' ><a
class='SubCatText' href='http://www." & strDomainPath &
"?subcategory="
strResult += CStr(myReader("SubCategoryID"))
strResult += "' target='new'>" & myReader("SubCategory") &
"</a></td></tr>" & Environment.NewLine
Loop
End function

################################

the GetMenuList function populates a label which is referenced on my
aspx page..

I want to be able dynamically add a new category table to the page and
list all subcategories.. is there another way of doing this? i hate
dealing with html!

thanks

Vincent
Nov 19 '05 #1
1 1121
Sure, why don't you do nested databinding?
http://openmymind.net/index.aspx?documentId=8

Also, of note, when you are appending a lot of strings like you are doing,
it's better to use a System.Text.StringBuilder

dim strResult as new System.Text.StringBuilder

strResult.Append(Environemtn.NewLine)
strResult.Append("<table...")
http://www.c-sharpcorner.com/Code/20...uilderComp.asp
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Winshent" <wi*************@yahoo.co.uk> wrote in message
news:f5**************************@posting.google.c om...
I am trying to write a data driven menu. I am still a beginner so am
asking for advice.

My current method is to load all of the result into a html style
string using the following code:
############################
Public Function GetMenuList() As String
Do While myReader.Read()
strResult += Environment.NewLine
strResult += "<table class='CatMenu' ><tr><td
class='MenuCategory'>" & myReader("Category") & "</td></tr>" &
Environment.NewLine
strResult += GetSubCategories(CInt((myReader("CategoryID"))))
& "</table>" & Environment.NewLine
strResult += "<br />"
Loop
end function

Public Function GetSubCategories(ByVal CategoryID As Integer) As
String
load reader code etc..
Do While myReader.Read()
strResult += "<tr><td class='MenuSubCategory' ><a
class='SubCatText' href='http://www." & strDomainPath &
"?subcategory="
strResult += CStr(myReader("SubCategoryID"))
strResult += "' target='new'>" & myReader("SubCategory") &
"</a></td></tr>" & Environment.NewLine
Loop
End function

################################

the GetMenuList function populates a label which is referenced on my
aspx page..

I want to be able dynamically add a new category table to the page and
list all subcategories.. is there another way of doing this? i hate
dealing with html!

thanks

Vincent

Nov 19 '05 #2

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

Similar topics

0
by: John Davis | last post by:
I always heard the term "data/database driven programming" model in ASP database, SQL programming, and web programming circles. But I don't quite sure what does it mean? Does it mean the web...
15
by: DesignGuy | last post by:
I've inherited a site that has 1000+ product pages that follow a similar layout. I would like to import these pages into a database for ease of future updating. The pages have the usual banners,...
1
by: Ben Fidge | last post by:
What are best practices for page output caching on pages that are dynamically generated from database tables. Our site has left-hand navigation that is comprised of dynamically generated menus...
0
by: sampada | last post by:
hi all I am trying to develope tabs in asp.net aplication and that Tabs should be database driven That means menus of Tabs should get directly access from database . I am using Oracle database....
3
by: Nymus | last post by:
I would like to use an access database as a shared database on a remote website. I don't know if it is possible, but this is what i would like to do with this database: - Use it to run a database...
0
by: Nymus | last post by:
I would like to use an access database as a shared database on a remote website. I don't know if it is possible, but this is what i would like to do with this database: - Use it to run a database...
49
by: ARC | last post by:
Hello all, I have one chance to get this right, as I'm nearing a release of a program. I've looked at the database settings, and so far, have set the following: * Unchecked 'Enable design...
1
by: beaker | last post by:
Access Database-driven ASP page with embedded RSS feeds Hi, I know very little about web development in general - just some basic html scripting, CSS and a bit of XML. I've inherited a public...
25
by: pereges | last post by:
Hello, I'm trying to build a database driven website for a library management system. The database is stored on a remote server which all of my team mates can access. I've installed MySQL, PHP and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.