I have a List object in 1 controller and I was wondering how can I transfer it to the next controller for example this is what I have
public ActionResult namelist()
{
var mynames = new List<everyname>
{
new everyname{ firstname ="john", Lastname= "henny"},
new everyname{ firstname = "bob", Lastname = "cosso"},
new everyname{ firstname = "bill", Lastname = "luther"},
new everyname{ firstname ="mike", Lastname= "jones"}
};
return View(mynames);
}
// how can i transfer the above list with information into this action below
public ActionResult newlist()
{
// i tried transfering the list here and it did not work
var namelist = new namelist()
IEnumerable<SelectListItem> items = namelist.Select(c => new SelectListItem
{
Value = namelist,
Text = namelist
});
how can i transfer things? i am lost on this.
In the NameList method you can add this line:
then at the top of the newList method add this line:
Once you access a value in TempData it is purged from the TempData object