This article mainly introduced the Repeater event OnItemCommand obtains the line internal control method, the need friend may refer to the
Record, mainly this sentence:
TextBox txtnum = E.item.findcontrol ("Txtnum") as TextBox;
Repeater is so strong, so flexible. I don't need anything other than repeater.
The code is as follows:
<table>
<asp:repeater id= "rptlist" runat= "Server" onitemcommand= "Rptlist_itemcommand" >
<ItemTemplate>
<tr>
<td><asp:textbox id= "Txtnum" runat= "server" text= ' <% #Eval ("Pronum")%> ' ></asp:TextBox>< /TD>
<td><asp:button id= "btnupdate" runat= "Server" text= "Update" commandname= "Updates" commandargument= ' <% #Eval (" PID ")%> '/></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
The code is as follows:
protected void Rptlist_itemcommand (object source, RepeaterCommandEventArgs e)
{
Switch (e.commandname)
{
Case "Update":
string arg = E.commandargument.tostring ();//Get Parameters
It is useful to find the control of the line that fires the event, and to pass on more of the required parameter values.
TextBox txtnum = E.item.findcontrol ("Txtnum") as TextBox;
Perform business logic below
String jsstr = "<script>alert (' Delete succeeded!" + Txtnum.text + "') </script>";
Page.ClientScript.RegisterClientScriptBlock (this. GetType (), "alert", Jsstr,false);
Break
}
Bind ();
}