I'm trying to work with a class that has a child object, which has a string - and I'm trying to access this with in-line C# code on my aspx page.
More specifically, let's say I'm working with an object of 'Upload' class which has a Title property (String). An Upload object can also have a 'File' property (object). And each File object has a Url property (String).
I can access the Title like so:
<%# ((Upload)Container.DataItem)["Title"] %>
That works fine. But then how do I access a File's Url? Because the following does not work:
<%# ((File)((Upload)Container.DataItem)["File"]).Url %>
As you may be able to guess from the syntax, this is all within an asp repeater.
try this:
<%# ((Upload)Container.DataItem).File.Url %>
You get the container dataitem & cast it. Once you have the object, you can call it's properties & methods like any other object