Click here to Skip to main content
15,894,252 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I don't no how to save the list of values in DataAccessLayer in mv4
XML
public ActionResult SaveMultiple(List<EmployeeDetails> save)
        {
            foreach (var item in save)
            {
                save1(save);
            }
            return View();
        }

XML
public Boolean save1(List<EmployeeDetails> save)
        {
            con.Open();
            List<EmployeeDetails> emp = new List<EmployeeDetails>();
            con.Close();
           return true;

       }
Posted
Comments
[no name] 22-Jul-15 7:48am    
You need to learn ADO.NET, https://msdn.microsoft.com/en-us/library/e80y5yhx(v=vs.110).aspx and probably some SQL wouldn't hurt either.

1 solution

Please have a look into the below sample example of a Controller Action method which is used to bulk update data using Entity Framework:-

C#
[HttpPost]
public ActionResult Index(List<Contact> contactList)
{
	using (ContactEntities contactEntities = new ContactEntities())
        {
              foreach (var contact in contactList)
              {
                 var cnct = contactEntities.Contacts.Where(c => c.ContactID.Equals(contact.ContactID)).FirstOrDefault();
                 if (cnct != null)
                 {
                     cnct.ContactPerson = contact.ContactPerson;
                     cnct.Contactno = contact.Contactno;
                     cnct.EmailID = contact.EmailID;
                 }
              }
                 contactEntities.SaveChanges();
         }
              ViewBag.Message = "Successfully Updated.";
              return View(contactList);
}


Hope this will be of help to you.
 
Share this answer
 
v2

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