protected void btnConfirmTableNumber_Click(object sender, EventArgs e) { var q = from i in dc.Tbltables.ToList() select new { ID = i.Tablename, TableNumber = i.Tabledescription, }; if (q.Where(z => z.TableNumber == txtTableNumber.Text).Count() > 0) { CheckTableIsCorrect(txtTableNumber.Text); } else { Messagebox.ShowAlert("Table not exist."); } }