asp.net mvc - Original values sometimes remain after edit and reload -


mvc5 web app. have basic edit method:

    public actionresult edit(int studentid)     {         studentmodel model = repo.getstudent(studentid);         return partialview("_editlot", model);     } 

and save post:

    [httppost]     [validateantiforgerytoken]     public actionresult edit(studentmodel model)     {         repo.updatestudent(model);         return redirecttoaction("index", "subject", new { subjectid = model.studentid });     } 

so post edit, save data in repo direct index method reloads (index contains student list subject edit link in table each student).

    public actionresult index(int classid)     {          classviewmodel model = new classdataviewmodel()          {              studentlist = repo.getstudents(classid)          };          return view(model);     } 

edit: index view has table of student data:

@model myapp.models.subjectviewmodel  <table class="table table-responsive processor-data-table">     <thead>         <tr>             <th>                 first name             </th>             <th>                 last name             </th>             <th>                 dob             </th>             <th>                 grade             </th>             <th>edit</th>         </tr>     </thead>     <tbody>         (var = 0; < model.studentlist.count(); i++)         {             <tr>                 <td>                     @html.displayfor(modelitem => model.studentlist[i].firstname)                 </td>                 <td>                     @html.displayfor(modelitem => model.studentlist[i].lastname)                 </td>                 <td>                     @html.displayfor(modelitem => model.studentlist[i].dob)                 </td>                 <td>                     @html.displayfor(modelitem => model.studentlist[i].grade)                 </td>                     <a href="@url.action("edit", "student", new { @studentid = model.studentlist[i].studentid })" class="btn btn-info modal-link"><span class="glyphicon glyphicon-pencil"></span></a>                 </td>             </tr>         }     </tbody> </table> 

i found original values still showing after save , reload when testing in chrome , ie 10 or higher. example changed dob student , original dob remains int index table after reload.

i had been pressing enter submit form , suspected enter key triggering cancel button cancel button of type="button" don't think possible.

i added edit method (not post) , fixed issue in chrome:

    [outputcache(location = system.web.ui.outputcachelocation.none, nostore = true)] 

... still getting intermittent old values on index view in ie, out of 10 tests, 3 times have old values in index list.

edit: asked see repo update method:

public void updatestudent(studentmodel model) {     using (var db = new schoolentities())     {         student student = new student()         {             studentid = model.studentid,             firstname = model.firstname,             lastname = model.lastname,             grade = model.grade,             dob = model.dob         };          db.entry(student).state = system.data.entity.entitystate.modified;         db.savechanges();     } } 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -