Link to home
Create AccountLog in
Avatar of elliottbenzle
elliottbenzle

asked on

vb.net help passing a variable into a sub

I have a repeater where I would like to pass the id of the current record into a sub.
I tried using <%Tester(Eval("id"))%> within the repeater bt am getting the error:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

How would I get this to work. I've posted my code below.
Thanks

<asp:Repeater id="events_menu_hw" runat="server">
    <HeaderTemplate>
    </HeaderTemplate>
    <ItemTemplate>
    <li>
    <%Tester(Eval("id"))%>
    <a href="hw-test.aspx?hwid=<%#Eval("id")%>">
    <%#Eval("title_var")%>
    </a>
    </li>
    </ItemTemplate>
    <FooterTemplate>
    </FooterTemplate>
    </asp:Repeater>

Sub Tester(ByVal menu_var As String)
        Response.Write(menu_var)
    End Sub
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Why go through the sub. Why not just add the item directly as you did with the hyperlink?
As tommyboy says, can u tell us wht u r tryin 2 achieve. Maybe u need a change in design approach.
Avatar of elliottbenzle
elliottbenzle

ASKER

I am trying to create a menu with a 2nd level drop down.The current loop you see is the 1st level and the second level will need to select the sub menu items from the database. So the sub 'Tester' will eventually be used to select the correct sub level menu items from the database. and display them.
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I'll try it out. Thanks for the help.