Hi Teena
I hope this can help you:
private void datagridview _CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex = datagridview.Column"Col_DeButton"].Index)
return;
else
{
int iRtnVal = 0;
SqlConnection sqlConn = new SqlConnection(Conexion);
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandText = "DELETE FROM ...";
sqlCmd.Connection = sqlConn;
try
{
sqlCmd.Connection.Open();
iRtnVal = sqlCmd.ExecuteNonQuery();
}
catch (Exception Ex)
{
Thread.CurrentThread.Abort();
}
finally
{
sqlCmd.Connection.Close();
}
SqlDataAdapter sqlAdapt = new SqlDataAdapter("SELECT * FROM ...", sqlConn);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
try
{
sqlConn.Open();
sqlAdapt.Fill(ds, "Datas");
}
catch (Exception Ex)
{
Thread.CurrentThread.Abort();
}
finally
{
sqlConn.Close();
}
if (ds.Tables["Datos"] != null)
dt = ds.Tables["Data"];
else
dt = null;
datagridview.datasource = dt;
}
}