Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. @for(int i = 0; i < Model.Count(); ++i) {
  2. @Html.HiddenFor(m => m[i].Id)
  3. // send other properties
  4. }
  5.  
  6. public ActionResult Import(HttpPostedFileBase excelfile)
  7. {
  8. //Code to get data from Excel sheet
  9. for( int row =2; row <=range.Rows.Count; row++)
  10. {
  11. Employeelist emp = new Employeelist();
  12. emp.ID =((Excel.Range)range.Cells[row,1]).Text;
  13. obj.Add(emp);
  14. }
  15. TempData["doc"] = obj;
  16. return View("success", obj);
  17. }
  18.  
  19. @model IEnumerable<AzSample.Models.Employeelist>
  20. @using (Html.BeginForm("Save","Home", FormMethod.Post))
  21. {
  22. @Html.AntiForgeryToken()
  23. <h2>Employees Details</h2>
  24. <div>
  25. <table>
  26. <tr>
  27. <th>Id</th>
  28.  
  29. </tr>
  30. @{var list = (List<AzSample.Models.Employeelist>)TempData["doc"];}
  31. @{TempData["doc"] = list;}
  32. @foreach (var emp in list)
  33. {
  34. <tr>
  35. <td>@emp.ID</td>
  36. </tr>
  37. }
  38. </table>
  39.  
  40. <button type="submit" value="save" onclick="@Url.Action("Save", "Home")">Save</button>
  41. </div>
  42. }
  43.  
  44. [HttpPost]
  45. public ActionResult Save()
  46. {
  47. if (TempData["doc"] != null)
  48. {
  49. // Your code will be here
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement