Repeater 中产生事件引用(类 button)的写法
[HTML]
<asp:repeater runat="server">
<ItemTemplate>
<tr>
........
<td align="center" bgColor="#ffffff">
<asp:ImageButton CommandName="Delete" ImageUrl="/MemberServices/images/del.gif" runat="server"></asp:ImageButton>
</td>
</tr>
</ItemTemplate>
</asp:repeater>
[C#]
private void Repeater1_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
if(e.CommandName == "Delete")//与Repeater定义要执行的事件对应
{
HtmlInputHidden Idhid = (HtmlInputHidden)e.Item.FindControl("HiddenID");
string ID = Idhid.Value;
int ii= Csales_da.Delete( Convert.ToInt32(ID) );//删除函数(数据层)
if(ii==1)
{
Response.Write("<script>alert('删除成功!');</script>");
ViewState["RecordCount"] = null;
getCsales( (int)ViewState["Pindex"] ,18);//数据绑定
}
}
}