Hey all I am new to the MVC world and was wanting to get a few values from the TempData that I made that houses 3 DataSet's inside it.
The values that are inside the TempData are these:
then selecting tTrip then rows then Results View:
finally seeing the DataSet values for tTrip:
I populate the TempData like so (simplify):
allData.Merge("tEvents"); //Gathers data and places it into tEvents
allData.Merge("tTrip"); //Gathers data and places it into tTrip
allData.Merge("tExternalTrainingMain"); //Gathers data and places it into tExternalTrainingMain
TempData["jsonData"] = allData;
I've tried:
string blah = TempData["jsonData"][0]["somename"].toString();
string blah = TempData["jsonData"][0].somename.toString();
string blah = TempData["jsonData"][0][0].somename.toString();
string blah = TempData["jsonData"][0][0][0].toString();
But only get errors. What is the proper way of getting the dataset values out of the TempData array?
UPDATE for DavidG
The indexed property that gives you the value from TempData
returns a object of type object
. You need to cast your value to the desired type. For example:
var myDataSet = TempData["jsonData"] as DataSet;
if(myDataSet != null)
{
We have a dataset now!
string blah = myDataSet.Tables[0]["somename"].toString();
}