foreach (DataGridViewRow item in Dashboard_dataGrid.Rows) { //--[0] is the index of the checkbox Column on the Datagridview if (Convert.ToBoolean(item.Cells[0].Value) == true) //if switched to false it works or add true) continue; { MessageBox.Show("Selected Rows :" + item.Cells[0].RowIndex.ToString()); //just to show where I am at in the index sqlCon.Open(); SqlDataAdapter abc = new SqlDataAdapter("Delete from tbl_ClientProducts Where productID = '" + item.Cells[11].Value.ToString() + "' and userID = '" + UtilityClass.userID + "'", sqlCon); DataTable dtbl = new DataTable(); abc.Fill(dtbl); Dashboard_dataGrid.Update(); //did not work Dashboard_dataGrid.Refresh(); // did not work sqlCon.Close(); } } MessageBox.Show("Your product(s) have been deleted Successfully");
if (Convert.ToBoolean(item.Cells[0].Value) == false)
"Delete from tbl_ClientProducts Where productID = '" + item.Cells[11].Value.ToString() + "' and userID = '" + UtilityClass.userID + "'"
SqlDataAdapter abc = new SqlDataAdapter("Delete from tbl_ClientProducts Where productID = @productID and userID = @userID", sqlCon); abc.SelectCommand.Parameters.Add("@productID", item.Cells[11].Value); abc.SelectCommand.Parameters.Add("@userID, UtilityClass.userID);
foreach (DataGridViewRow item in Dashboard_dataGrid.Rows) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)item.Cells[0]; //--[0] is the index of the checkbox Column on the Datagridview if (chk.TrueValue) { //your logic here... } }
null
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)