Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > MENU Control ~

Reply
Thread Tools

MENU Control ~

 
 
Brad Isaacs
Guest
Posts: n/a
 
      02-05-2007
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 default.aspx page and use it in my
sql parameter @languageID.




At the moment I have hard coded the languageID value into my string Select
statement as "1"

My code:

' Get the data from the database and create the top-level menu items

Sub PopulateMenu()

Dim dst As DataSet = GetMenuData()

For Each masterRow As DataRow In dst.Tables("org").Rows()

Dim masterItem As New MenuItem(masterRow("otherName").ToString())

CrownCorpMenu.Items.Add(masterItem)

Next

End Sub

' Use a DataAdapter and DataTSet to grab the database data

Private Function GetMenuData() As DataSet

' Retrieve the data from the org table

Dim selectCommand As String = "SELECT * FROM org WHERE (languageID = 1)"

Dim dad As SqlDataAdapter = New SqlDataAdapter(selectCommand, conTBS)

Dim dstOrg As DataSet = New DataSet()

dad.Fill(dstOrg, "org")

Return dstOrg

End Function



I do realize that I must use something like the following:

Dim cmd As New SqlCommand("Select * From org WHERE (languageID =
@languageID)"

cmd.Parameters.AddWithValue("@languageID", languageID)



I tried using request.form("langID") / request.QueryString("langID") to
extract the value langID from the default.aspx page but I keeping getting a
returned value of NULL.


Any help would be greatly appreciated,

Thanks in advance,

~Brad



--
------------------------------
Brad Isaacs
Developer, Consultant
www.webdevcreations.com
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
 
Brad Isaacs
Guest
Posts: n/a
 
      02-05-2007
Dear Group,

I have resolved my issue. I finally figured out that it really helps when
you use
Request.QueryString
against the CORRECT
value..........................................^#% #$%^$#!!

lol......

If Not Page.IsPostBack Then

If Request.QueryString("lang") = "" Then

languageID = "1"



Else

languageID = "2"

End If



Then down in my SQL Query I used >>>>

Retrieve the data from the org table

Dim selectCommand As String = "SELECT * FROM org WHERE languageID = " &
languageID

And that solved my issue........


Thanks,

~Brad


"Brad Isaacs" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 default.aspx page and use it in
> my sql parameter @languageID.
>
>
>
>
> At the moment I have hard coded the languageID value into my string Select
> statement as "1"
>
> My code:
>
> ' Get the data from the database and create the top-level menu items
>
> Sub PopulateMenu()
>
> Dim dst As DataSet = GetMenuData()
>
> For Each masterRow As DataRow In dst.Tables("org").Rows()
>
> Dim masterItem As New MenuItem(masterRow("otherName").ToString())
>
> CrownCorpMenu.Items.Add(masterItem)
>
> Next
>
> End Sub
>
> ' Use a DataAdapter and DataTSet to grab the database data
>
> Private Function GetMenuData() As DataSet
>
> ' Retrieve the data from the org table
>
> Dim selectCommand As String = "SELECT * FROM org WHERE (languageID = 1)"
>
> Dim dad As SqlDataAdapter = New SqlDataAdapter(selectCommand, conTBS)
>
> Dim dstOrg As DataSet = New DataSet()
>
> dad.Fill(dstOrg, "org")
>
> Return dstOrg
>
> End Function
>
>
>
> I do realize that I must use something like the following:
>
> Dim cmd As New SqlCommand("Select * From org WHERE (languageID =
> @languageID)"
>
> cmd.Parameters.AddWithValue("@languageID", languageID)
>
>
>
> I tried using request.form("langID") / request.QueryString("langID") to
> extract the value langID from the default.aspx page but I keeping getting
> a returned value of NULL.
>
>
> Any help would be greatly appreciated,
>
> Thanks in advance,
>
> ~Brad
>
>
>
> --
> ------------------------------
> Brad Isaacs
> Developer, Consultant
> www.webdevcreations.com
> (E-Mail Removed)
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Menu Control and Sitemap, eliminate the home column on the menu display empire5 ASP .Net 1 01-11-2007 03:30 AM
How do I set selected Menu item in a asp:menu control? goran.strand@gmail.com ASP .Net 0 12-22-2006 08:05 AM
Horizontal Menu Navigation Web Control - Spaces Between Menu Items Philip ASP .Net Web Controls 1 03-21-2006 01:55 PM
Iterating through all the menu/child items in a menu control Bryan ASP .Net 1 03-01-2006 09:38 AM
Adding Access keys to menu items in the Menu control Mike Tavares ASP .Net Web Controls 2 01-05-2006 11:06 AM



Advertisments