Rank: Member Groups: Member
Joined: 6/23/2010 Posts: 18
|
I have created a menu user control populated by data retreived from a stored procedure. The code behind the menu user control is below. The menu user control is inserted into a main page but the code in the user control is not getting executed when the main page is loaded. Can someone points out how to force the execution of the code from the main page so that the menu will be populated with the appropriate menu items?
Public Class menucontrol Inherits UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub Protected WithEvents Menu1 As EO.Web.Menu
'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim objCmd = New SqlCommand("pt_menu") With objCmd.Parameters .Add(DBCreateParam("@securitycode", SqlDbType.VarChar, "admin")) End With Dim dr As DataSet = DBExecuteDataSet_Menu(objCmd) ' Specify the data source. Here we bind to the Menu. You ' can also bind to any sub menu.
Menu1.DataSource = dr
' Bind the "Website" column in the table to ' "NavigateUrl" property.
Dim binding As New EO.Web.DataBinding Menu1.DataFields = "level1|level2|level3|level4" binding.DataField = "menulink" binding.Property = "NavigateUrl" Menu1.Bindings.Add(binding)
' Populate from the data source (mainTable);
Menu1.DataBind()
End Sub 'Page_Load
End Class
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Your code looks fine with us. You may want to test the structure with a blank page and a blank user control and debug from there.
Thanks!
|