<%@ Page Language="C#"%>
<script runat="server">
	void R1_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {
		Label1.Text ="Você clicou o botão: " +((Button)e.CommandSource).Text;
	}
</script>
<html>
	<head id="Head1" runat="server">
		<title>Exemplo com o evento ItemCommand do controle Repeater</title>
	</head>
	<body>
		<form id="form1" runat="server">
			<div>
				<asp:Label ID="Label1" runat="server" Text="Clique nos botões" Font-Bold="True"></asp:Label><p />
				<asp:SqlDataSource
					id="SqlDataSource1"
					runat="server" ProviderName="System.Data.SqlClient" 
					DataSourceMode="DataReader"
					ConnectionString="<%$ ConnectionStrings:nwind%>"
					SelectCommand="SELECT CustomerID, CompanyName FROM Customers">
				</asp:SqlDataSource>
				<asp:Repeater ID="Repeater1" OnItemCommand="R1_ItemCommand" 
				DataSourceID="SqlDataSource1" runat="server">
					<HeaderTemplate>
						<table>
							<tr>
								<th>ID cliente</th>
								<th>Nome da empresa</th>
							</tr>
					</HeaderTemplate>
					<ItemTemplate>
						<tr>
							<td bgcolor="#CCFFCC">
								<asp:Button ID="Button1" runat="server" 
								Text='<%# Eval("CustomerID") %>' />
							</td>
							<td bgcolor="#CCFFCC">
								<asp:Label runat="server" ID="lblCompanyName" 
								text='<%# Eval("CompanyName") %>' />
							</td>
						</tr>
					</ItemTemplate>
					<AlternatingItemTemplate>
						<tr>
							<td>
								<asp:Button ID="Button2" runat="server" 
								Text='<%# Eval("CustomerID") %>'/>
							</td>
							<td>
								<asp:Label runat="server" ID="Label4" 
								text='<%# Eval("CompanyName") %>' />
							</td>
						</tr>
					</AlternatingItemTemplate>
					<FooterTemplate>
						</table>
					</FooterTemplate>
				</asp:Repeater>
			</div>
		</form> 
	</body>
</html>

