[ASP.NET][Control] Repeater 加入 asp.net的控制項

摘要:[ASP.NET]Repeater 加入 asp.net的控制項

 

.aspx

01 <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="Repeater1_ItemCommand">  
02 <ItemTemplate>  
03 <div>  
04 <asp:Label ID="Label1" runat="server" Text='<%# Eval("Sales_No")%>'></asp:Label>  
05 <asp:Label ID="Label2" runat="server" Value='<%# Eval("Sales_Name")%>'></asp:Label>  
06 <asp:Button ID="Button1" runat="server" Text="Button" CommandName="ShowSaleMoney" CommandArgument='<%# Eval("Sales_SaleMoney")%>' />  
07 </div>  
08 </ItemTemplate>  
09 </asp:Repeater>  
10 <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>

.aspx.cs
 

1 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)  
2 {  
3     if (e.CommandName == "ShowSaleMoney") Label1.Text = e.CommandArgument.ToString();
4 }

PS.   EnableViewState = true