int totalCount = GridView1.Rows.Cast<GridViewRow>() .Count(r => ((CheckBox)r.FindControl("chkSelect")).Checked); // maybe: if(totalCount > 0) UpdateProduct(totalCount);