我正在尝试创建一个允许用户退订接收报告的网页。
到目前为止,我已经创建了页面。用户可以查看他们收到的所有报告
我还写了一个“更新替换”语句,不幸的是,这会更新所有内容。
我的问题是我如何修改我的代码以一次只删除一行,即使下一行中的信息相同
请在下面查看我的代码
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
System.Web.UI.WebControls.Label rollno = GridView1.Rows[e.RowIndex].FindControl("Label1") as System.Web.UI.WebControls.Label;
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "UPDATE Subscriptions SET Subscriptions.ExtensionSettings = REPLACE('Subscriptions.ExtensionSettings', @ReportSearch, '') WHERE Subscriptions.ExtensionSettings like '@ReportSearch'" ;
cmd.Parameters.AddWithValue("ReportSearch", TxtSearch.Text);
cmd.Connection = con;
cmd.ExecuteNonQuery();
GridView1.EditIndex = -1;
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
}