locked
using <%# Eval("Text") %> with menu adapter RRS feed

  • Question

  • User-1168223385 posted

    Hi there in need to use the menu adapter from the tool kit

    Problem I have is that my menu is populated at runtime using vb

    the code is as follows

    VB

    'loop for all selected nodes

    For i = 0 To xmncount - 1

    'create menuitem instance

    Dim Tab1Item As New MenuItem

    'assign nodlist value to menuitem instance

    Tab1Item.Text = xmn(i).Value

    'assign page name to menuitem instance navigation url

    Tab1Item.NavigateUrl = "~/Tab" & i + 1 & "pages/men1.aspx"

    'add new menu item from menuitem instance

    tabmenu.Items.Add(Tab1Item)

    Next i

    asp.net

    <asp:Menu ID="tabmenu" runat="server" Orientation="Horizontal" CssClass="tabmenu">

    <StaticItemTemplate>

    <%# Eval("Text") %>

    </StaticItemTemplate>

    <StaticMenuItemStyle CssClass="tablink" ItemSpacing="0"/>

    <StaticHoverStyle CssClass="tablinkhover" />

    <StaticSelectedStyle CssClass="tablinkatvive" />

    </asp:Menu>

     this works fine till i try to use the adpter and it then says that eval can only be used for a databound control

    why is this happening it works great without the adapter but i need to use the adapter as i need to have the menu list styled

    any ideas or help

    Lee

    Saturday, March 17, 2007 6:37 PM

Answers

  • User-1168223385 posted

    Hi all

    Found the answer

    Just change

    # Eval("Text") %>

    to

    <%#container.DataItem.NavigateUrl%>

    this works great

    Thanks all

    Lee

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 18, 2007 12:48 PM

All replies

  • User-1168223385 posted

    Hi all

    Found the answer

    Just change

    # Eval("Text") %>

    to

    <%#container.DataItem.NavigateUrl%>

    this works great

    Thanks all

    Lee

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 18, 2007 12:48 PM
  • User-319159958 posted
    OK im having th e exact same problem except that its cause my menu is a Static Template but uses the

    # Eval("Text") %>  just the same and gives the exact same error.

     I dont understand why I would change it to <%#container.DataItem.NavigateUrl%>.... why??? =whats that container? and that navigateURL???

    anyway after doing it it just gave me a blank page instaed of my page

    Tuesday, March 20, 2007 10:11 PM
  • User-319159958 posted

    ok I resolved it by changing (i figured) the navigateURL to the Text property and it works

     

    Thank you

    Tuesday, March 20, 2007 10:13 PM
  • User-1185540306 posted

    Sorry, I have the same problem. I don't understand why I have to use  <%#container.DataItem.NavigateUrl%>

    What is container for? When I use it, I get this error: CS0103: The name 'container' does not exist in the current context

     I hope you can help me.

    Tuesday, December 18, 2007 11:39 PM