Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Controller Action method code :
C#
[HttpGet]
public ActionResult Create()
{
  return View();
}

[HttpPost]
public ActionResult Create(FormCollection formCollection)
{
  Employee employee = new Employee();
  // Retrieve form data using form collection
  employee.Name = formCollection["Name"];
  employee.Gender = formCollection["Gender"];
  employee.City = formCollection["City"];
  employee.DateOfBirth = Convert.ToDateTime(formCollection["DateOfBirth"]);

  businesslayer.AddEmmployee(employee);
  TempData["Employees"] = employee;
  return RedirectToAction("Testtempdata");
}

public ActionResult Testtempdata()
{
  Employee employee = TempData["Employees"] as Employee;
  return View(employee);
}

Views Related to Actionmethods:
HTML
Index View:
{
  ViewBag.Title = "Index";
}

<h2>Index</h2>
@Html.ActionLink("Testtempdata","Testtempdata")

Tempdata view:
HTML
@model 
@{
  ViewBag.Title = "Testtempdata";
}

<h2>Testtempdata</h2>

@{Html.BeginForm("Testtempdata", "Testtempdata", FormMethod.Post);}
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td class="inner_databg">
    </td>
  </tr>
  <tr>
  </tr>
</table>

Here In TEmpdata view i would like to retrieve the tempdata values. getting by employee object what code i need to write in tempdataview.
Some one help me
Thanks in advance:
Posted
Updated 22-Mar-15 21:57pm
v2

1 solution

Change your view model return to Employee like below
C#
@model Employee
@{
  ViewBag.Title = "Testtempdata";
}
//then you can access employee values like this

<p>@Model.EmployeeProperty1</p>


Hope this helps
 
Share this answer
 
Comments
raxhemanth 23-Mar-15 5:13am    
Thankyou so much jameel VM

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