删除评论

xiaoxiao2026-04-12  5

#region 删除评论            /// <summary>      /// 删除评论      /// </summary>      /// <param name="id"></param>      /// <returns></returns>      public bool Delete(string id)      {          bool flag = false;          string sql = "delete from comment where id=@id";          SqlParameter[] para = new SqlParameter[] {           new SqlParameter("@id",id)          };            int ins = sqlhelper.ExecuteNonQuery(sql,para,CommandType.Text);            if (ins>0)            {                flag = true;            }          return flag;      }      #endregion

 

 

                <asp:LinkButton CommandArgument='<%#Eval("id") %>' ID="Lbtndel" OnClientClick="return confirm('是否真的要删除该评论?')" runat="server" OnClick="Lbtndel_Click">删除</asp:LinkButton>

 

 

 protected void Lbtndel_Click(object sender, EventArgs e)    {        //当前点击的按钮        LinkButton lb = (LinkButton)sender;        //获取传过来的commid;        string id = lb.CommandArgument;

        new CommentBLL().Delete(id);        //绑定评论        string newsid = Request.QueryString["newsid"];        repComment.DataSource = new CommentBLL().SelectComment(newsid);        repComment.DataBind();    }

 

 

<%@ Page Language="C#" MasterPageFile="~/Common.master" AutoEventWireup="true" CodeFile="NewsContent.aspx.cs"    Inherits="NewsContent" Title="新闻内容页面" MaintainScrollPositionOnPostback="true" %>

//删除后记住滚动条

 

转载请注明原文地址: https://www.6miu.com/read-5047251.html

最新回复(0)