Another quick example for your reference:
protected void btnClose_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
if(row.Cells[index].Text.Trim().ToLower() == "pending"){
ClientScript.RegisterStartupScript(typeOf(this), "alert", "alert('Found pending status.')", true);
break;
}
}
}
To display a confirmation from the code-behind, then you may refer this example
here.