Repeater 实现删除

<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Delete" CommandArgument='<%# Eval("XiangceId") %>'
                                                        OnClientClick="return confirm( '你确定要删除这条记录? '); ">删除</asp:LinkButton>

cs页面

protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument);//得到Id...就这2句重要..
        if (e.CommandName == "Delete")//要和aspx名称一样...下面的按自己的写法.就可以了
        {
            //string strsql = "update  Xiangce set  where XiangceId=" + id;//放入回收站
            string strsql = "delete FROM [Xiangce] where XiangceId=" + id;//这句是直接删除.删除语句
            //Response.Write(strsql);
            DAL.SqlServer2000.RunSql(strsql);//这句我写的类库.

            ClassMessage.ShowAndRedirect(this.Page, "删除成功!", "T_pic_Sort.aspx");//页面跳转
        }


}
posted on 2009-08-31 11:28  周奇  阅读(533)  评论(1编辑  收藏  举报