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
--
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
--