I have a custom method that returns a collection:
Course[] catalog = clnt.GetCatalog(new Guid(CurrentUser.MembershipGUID));
I then pass it to my ViewData object:
ViewData["catalog"] = catalog;
But when i try to access it on my aspx page like so:
var catalog = ViewData["catalog"] as Course[];
Here’s the method being called:
public List<Course> GetCatalog()
{
using (var db = new BALmsDBContainer())
{
List<Course> lst = db.Courses.Include(i => i.Vendor).ToList();
return lst;
}
}
I get catalog is null. My ViewData[“catalog”] object is not null. 100% guarantee on that. How do i cast the ViewData[“catalog”] object back to Course[]?
The “as” operator is actually different from an explicit cast, as mentioned here: http://msdn.microsoft.com/en-us/library/cscsdfbt(v=vs.100).aspx