• .net Repeater内部的按钮事件代码demo(Repeater内button的删除事件)


    .net  Repeater内部的按钮事件代码demo(Repeater内button的删除事件)

    <asp:Repeater ID="Repeater1" runat="server" >
             <ItemTemplate>  
          <tr height="60" style="border-bottom:1px #ccc solid; 100%">
          <td ><%#Eval("ID")%></td>
    <td ><img src="<%# Eval("pingtu ") %>" width="80" height="50" /></td>
    <td ><%#Eval("pingming")%></td>
    <td ><%# Convert.ToDateTime(Eval("addTime")).ToString("yyyy-MM-dd")%></td>
    
    
    <td >  
       <a href="editcp.aspx?ID=<%#Eval("ID") %>">编辑</a>
    
    <asp:Button ID="Button1" runat="server" Text="删除" CommandArgument='<%#Eval("ID") %>' OnClientClick="return confirm('确认删除?')" 
            onclick="Button1_Click" />
    
         
     
    </td>
          </tr>
          
             </ItemTemplate>
            </asp:Repeater>
    View Code
     protected void Button1_Click(object sender, EventArgs e)
            {
                Button btn = sender as Button;
                int id = int.Parse(btn.CommandArgument);
                //删除操作
                string sql = "delete from  tb_chanpin where ID ='" + id + "' ";
                BaseClass.ExecNonQuery(sql);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language=javascript>window.location.href=window.location.href; </script>");
            }
  • 相关阅读:
    ltp-ddt makefile的思考
    Linux configure,make,make install
    linux下can调试工具canutils安装过程记录
    windows下运行jar
    悲观锁
    mysql事务锁表
    静态内部类
    局部类
    匿名内部类(new类时覆盖类中方法)
    回文字
  • 原文地址:https://www.cnblogs.com/huichao1314/p/7661622.html
Copyright © 2020-2023  润新知