The repeater control doesn't have a DataKeys collection like the DataGrid so you have to come up with something a little different to get at the data you are binding to the control.
The way I would do something like this is like this:
1. Create a literal control inside the item template. Set the text of this control to the key of your data.
2. Create some server control in the template(s). Use anything you want that will generate a postback. Any postback event that occurs inside a repeater will fire off the Repeater.ItemCommand event.
<asp:repeater id="Repeater1" runat="server">
<itemtemplate>
<asp:button runat="server" text="Click Me" />
<asp:literal runat="server" id="litUserID" text='<%# DataBinder.Eval(Container.DataItem, "USER_ID") %>' />
</itemtemplate>
</asp:repeater>
3. In the ItemCommand event handler, find the literal control in the repeater item and get the text.
4. Perform your server side functions with the key that you pulled from the literal text.
Private Sub Repeater1_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs ) Handles Repeater1.ItemCommand
Response.Write(CType(e.Item.FindControl("litUserID "), Literal).Text)
End Sub
-
Peter