Menu Problem

S

SV

I'm trying to create a menu who's first level is generated from a
database stored procedure based on the user. The second and third
levels are pulled from a table and are the same for all users. To do
this, I've created a PopulateMenu Sub which fills the first level and
then calls a recursive sub, GetMenuSubItems, to fill the second and
third levels. I need the third level menu items value to update a
database when clicked, and also navigate to a new page. This is the
code I have for the recursive sub:

Private Sub GetMenuSubItems(ByRef Item As MenuItem, Optional ByVal
Parent_ID As Integer = 0)

Dim conn As New
SqlConnection(ConfigurationManager.ConnectionStrings("Admin").ConnectionString)
Dim cmd As New SqlCommand("sproc_get_menusubitems", conn)

cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Parameters.Add("@parentid", Data.SqlDbType.Int)
cmd.Parameters("@parentid").Value = Parent_ID

conn.Open()

Dim reader As SqlDataReader
reader = cmd.ExecuteReader

While reader.Read()
Dim SubItem As MenuItem
SubItem = New MenuItem(reader("Title"), Item.Value)
Item.ChildItems.Add(SubItem)
GetMenuSubItems(SubItem, reader("ID"))
End While

reader.Close()
conn.Close()

End Sub

The menu click event uses Item.Value to update the database. However
when I try to add the url in:

SubItem = New MenuItem(reader("Title"), Item.Value, "", reader("Url"))

The database does not update because the menu click event does not
fire. Any idea why this happens? Or how I can fix it?
 

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

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top