I am trying to create a webpage that allow users to unsubscribe from receiving the report.
So far I have created the page. users are able to see all the reports that they are receiving
I have also written an "update replace" statement that, unfortunately this updates everything.
My question is how do I modify my code to only delete one line at a time even if the same info is in the next line
Please see my code below
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();
}