• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Button click within repeater VB

Hi I have the following repeater, its displaying a list of products that have been displayed due to certain criteria specified.
I have added 2 button, but i don't know how i can access the button click on event on them, as they are within the repeater...
when i click one of the buttons, i need to capture the productID for the item within the repeater it is clicked for... below is the code for the repeater....
could any one help me, using VB code?

<asp:Repeater ID="repFavourites" runat="server">
<div style="border: 1px black solid;margin-bottom:5px;">
<a href="Product.aspx?ProductID=<%#Container.DataItem("ProductID")%>"><%#Container.DataItem("Title")%></a>
<div style="height:150px;width:150px;">
<a href="Product.aspx?ProductID=<%#Container.DataItem("ProductID")%>">
<img alt="" height="150px" width="150px" src="images/<%#Container.DataItem("ImageURL")%>" border="0" /></a>
<div style="position:relative;top:-130px;left:160px">
<asp:Button ID="Button1" runat="server" Text="Remove From Favourites" />
<asp:Button ID="Button2" runat="server" Text="Purchase Item" />
1 Solution
This may work:

<asp:Button ID="Button1" runat="server" Text="Remove From Favourites" CommandArgument='<%# Eval("ProductID") %>' />

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim pid As String = DirectCast(sender, Button).CommandArgument
End Sub

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now