Click here to Skip to main content
14,973,970 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
public ActionResult Index()
   {
       TestEntities db = new TestEntities();
       TempData["Resultats"] = db.Sites.ToList();
       return View();
   }



public ActionResult GetName(string name)
       {

           if (!string.IsNullOrWhiteSpace(name))
           {
               IEnumerable<Resultat> resultats = Resultats.Where(resultat => resultat.Name == name).ToList();
               return Json(resultats, JsonRequestBehavior.AllowGet);
           }
           return null;
       }



System.ArgumentNullException : 'La valeur ne peut pas être null.
Nom du paramètre : source'


What I have tried:

I want to use this function to sort the list before displaying it on java script code
Posted
Updated 17-Dec-19 2:17am

1 solution

Check for things being null, for example what is "Resultats" in GetName?

result cannot be null source - Google Search[^]
   
Comments
Member 14663996 9-Dec-19 11:46am
   
Resultats = null in GetName
Member 14663996 9-Dec-19 11:50am
   
how to keep its value by entering the function ?
F-ES Sitecore 10-Dec-19 4:02am
   
You haven't posted where it is defined or what it comes from. If it is db.Sites.ToList() then don't bother storing it in tempdata, just retrieve it again in your method

var Resultats = db.Sites.ToList();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900