I have a generic list List<T> and I want to create a view that iterates the list and spits out the output.
I’m coming up against a couple of issues:
- I don’t know how to get my view.aspx to understand T
- I don’t know how to get it to render the correct partial for T
For instance, if I pass in a list of CustomObject1 then I want to render the partial CustomObject1.ascx and if I pass in a list of CustomObject2 the I want to render the partial CustomObject2.ascx.
Is there a simple way to do this that I’ve overlooked? I don’t want to have a different aspx for every type of list I want to use, I’m just generating a of items after all. So it’s a waste to have 15 different views to cover each type of list I’m going to need to use.
Any ideas or solutions would be gratefully received.
If your names are always going to match (CustomObject1 then I want to render the partial CustomObject1.ascx), then you could use the type name. So: