private bool checkIsRowSelected(DataGridView dg) { bool isRowSelected = false; //Loop through each row of datagridview foreach (DataGridViewRow check in dg.Rows) { //Assume first column is checkbox column if (check.Cells[0].Value != null) { //Get the value in a string string chkValue = check.Cells[0].Value.ToString(); if (chkValue != "0" && chkValue != "False") { //if any of the row is selected, change the value of bool variable isRowSelected = true; break; } } } //return the value return isRowSelected; }