2011-11-22 50 views

回答

4

您必須處理Repeater控件的ItemCommand事件。

標記:

<asp:Repeater ID="Repeater1" runat="server" 
     onitemcommand="Repeater1_ItemCommand"> 
     <ItemTemplate> 
      <asp:LinkButton 
        ID="LinkButton1" 
        runat="server" 
        CommandName="cmd" 
        CommandArgument='<%#Eval("Name") %>' 
        Text="Click Here" 
        > 
      </asp:LinkButton> 
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
     </ItemTemplate> 
    </asp:Repeater> 

代碼:

protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) 
    { 
     if (e.CommandName == "cmd") 
     { 
      TextBox tx = e.Item.FindControl("TextBox1") as TextBox; 
      tx.Text = e.CommandArgument.ToString(); 
     } 
    } 
+0

你可以給我一個例子 – ItayM

相關問題