P
Przemek
Hi,
I'm trying to create menu dynamically (populated with dataset). I want
to have it inside my div, which is inside another div and inside
contentplaceholder. Unfortunately I'm receiving null reference
expetions :/
Here is my aspx code:
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
<div class="column">
</div>
<div class="page" id="blogs">
<div id="sidebar">
<h3>Choose Category:</h3>
</div>
<div id="content">
<asp:Table ID="BlogTable" runat="server" Width="400px">
</asp:Table>
</div>
</div>
</asp:Content>
and my code-behind responsible for creating menu:
Private Sub RebuildCatView(ByVal ds As DataSet)
Dim catMenu As New Menu
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
Dim categoryItem As MenuItem = New
MenuItem(CType(dr("Category_Name"), String))
catMenu.Items.Add(categoryItem)
Next
Dim ctrl As New Control
ctrl = Me.FindControl("sidebar")
ctrl.Controls.Add(catMenu)
catMenu.DataBind()
End Sub
I'm receiving my exeption in line:
ctrl.Controls.Add(catMenu)
How can I resolve this problem?
Przemek
I'm trying to create menu dynamically (populated with dataset). I want
to have it inside my div, which is inside another div and inside
contentplaceholder. Unfortunately I'm receiving null reference
expetions :/
Here is my aspx code:
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
<div class="column">
</div>
<div class="page" id="blogs">
<div id="sidebar">
<h3>Choose Category:</h3>
</div>
<div id="content">
<asp:Table ID="BlogTable" runat="server" Width="400px">
</asp:Table>
</div>
</div>
</asp:Content>
and my code-behind responsible for creating menu:
Private Sub RebuildCatView(ByVal ds As DataSet)
Dim catMenu As New Menu
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
Dim categoryItem As MenuItem = New
MenuItem(CType(dr("Category_Name"), String))
catMenu.Items.Add(categoryItem)
Next
Dim ctrl As New Control
ctrl = Me.FindControl("sidebar")
ctrl.Controls.Add(catMenu)
catMenu.DataBind()
End Sub
I'm receiving my exeption in line:
ctrl.Controls.Add(catMenu)
How can I resolve this problem?
Przemek