how to remove IEnemurable in asp.net mvc
I have a view with
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<StudentInfo>>" %>
in my view开发者_JS百科 if i have IEnumerable I can do foreach..
but before that i need to access the properties for StudnetInfo..
StudentInfo clas having
Public class StudentInfo
{
public Studentdetails sd {get;set;}
public classDetails cd {get;set;}
}
<% foreach(var e in Model){%>
<div>
<%=Html.DisplayFor(x=>e.StdentEdit) %>
<div>
<span>
<% Html.RenderAction("Details", "Home", new { @t = e }); %>
</span>
</div>
</div>
<% } %>
please can anybody help me out.. how to get the properties of StudentInfo above the foreach loop...
if i remove IEnemurable I can do that.. but i need to have Ienemurable for RenderAction..
is there any other way we can achieve this? thanks
e will be of type StudentInfo, call:
e.GetType().GetProperties()
If you need to grab the generic argument type from your Model directly without iterating I recommend this existing SO question:
How to get the type of T from a member of a generic class or method?
(2nd answer should work for you)
精彩评论