MENU Control ~

Discussion in 'ASP .Net' started by Brad Isaacs, Feb 5, 2007.

  1. Brad Isaacs

    Brad Isaacs Guest

    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
     
    Brad Isaacs, Feb 5, 2007
    #1
    1. Advertising

  2. Brad Isaacs

    Brad Isaacs Guest

    Re:RESOLVED ~Thanksl ~

    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" <> wrote in message
    news:...
    > 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
    >
    >
    >
     
    Brad Isaacs, Feb 5, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryan
    Replies:
    1
    Views:
    789
    Steven Cheng[MSFT]
    Mar 1, 2006
  2. Replies:
    0
    Views:
    1,458
  3. empire5
    Replies:
    1
    Views:
    586
    =?Utf-8?B?UmVuZ2E=?=
    Jan 11, 2007
  4. Mike Tavares

    Adding Access keys to menu items in the Menu control

    Mike Tavares, Dec 23, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    421
  5. Philip
    Replies:
    1
    Views:
    324
Loading...

Share This Page