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
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("title_var")%>
</a>
</li>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
Sub Tester(ByVal menu_var As String)
Response.Write(menu_var)
End Sub
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.
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I'll try it out. Thanks for the help.