public void EnableButton(DateTime data) { DataTable dt = bll.getListTable(data); String list = ""; foreach (Button btn in splitContainer2.Panel1.Controls.OfType <Button>()) { //MessageBox.Show("đã đi qua đây"); btn.Enabled = true; } foreach (DataRow row in dt.Rows) { list = row["MaBan"].ToString()[row["MaBan"].ToString().Length - 1].ToString(); foreach (Button btn in splitContainer2.Panel1.Controls.OfType <Button>()) { if (btn.Name == list) { btn.Enabled = false; } } } }