Button click within repeater VB

Posted on 2009-04-30
Last Modified: 2012-05-06
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" />
Question by:VegMan99
    1 Comment
    LVL 16

    Accepted 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

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now