Attie

Attie

  • NA
  • 95
  • 2.3k

How to remove null values on button click?

Feb 19 2018 5:08 AM

Hi guys, I have a form with button "Select All Emails". Now the problem I have if I click the button it will display all emails in that "ContactEmail" field from the database, if there is no email created it will show "NULL". Now what I want is not to show anything if the field is null (no email created). Below my controller code;
 
public JsonResult GetAllUser(EmployeeModel objModelMail, string to)
{
        List Recyclers = new List();
        using (WasteRecyclersEntities db = new WasteRecyclersEntities())
         {
            var query = from q in db.Recyclers
            select q.ContactEmail;
            return new JsonResult { Data = query.ToList(), JsonRequestBehavior = JsonRequestBehavior.AllowGet };
         }
}

Answers (8)