I was reading up on temp data and wanted to know if you can use tempdata with two separate keys and add more than one value to those. I.e.
TempData["Id"] = "1";
TempData["Name"] = "Bob";
then we have another set of values to add in the tempdata:
TempData["Id"] = "2";
TempData["Name"] = "Jill";
Using those in an action method:
public ActionResult Index()
{
TempData["Id"] = 1;
TempData["Name"] = "Bob";
TempData["Id"] = 2;
TempData["Name"] = "Jill";
}
then accessing that in another action method without having it to override the values of the keys and just give the last set of id and name:
public ActionResult About()
{
int id;
string name;
if (TempData.ContainsKey("Id") && TempData.ContainsKey("Name"))
{
id = Convert.ToInt32(TempData["Id"]);
name = TempData["Name"].ToString();
}
}
Is there a way to display both Id's for Bob and Jill and both of their names when accessing it in the About()
action method without just only getting 2 for ID and Jill for name, returned?