I've created a gridview that contains a "DELETE" button, to delete the row.
My Code :
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string username = (string)Session["user"];
string path = this.GridView1.SelectedRow.Cells[3].Text;
Cart cart = new Cart();
cart.Deleteitem(path,username);
}
public void Deleteitem(string path, string username)
{
string sql = string.Format("DELETE FROM Cart WHERE path = '{0}' AND userid = '{1}' ", path, username);
DBC dbc = new DBC();
dbc.InsertUpdateDelete(sql);
}
public void InsertUpdateDelete(string sql)
{
this.cmd = new OleDbCommand(sql, this.con);
this.con.Open();
this.cmd.ExecuteNonQuery();
this.con.Close();
}
My problem that when I clock the "DELETE" button, nothing happen, nothing deleted, what's the problem ?