MENU Control ~

B

Brad Isaacs

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



--
 
B

Brad Isaacs

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top