开发者

Can I do something like this?

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<StudentInfo>>" %>

<% int i = 0; %>

<% foreach(var e in Model){%>
<div>
<% if(i==0) { %>
  <% Html.RenderAction("student", "home", new { @et = e}); %>
<% break;
   } %>
    <div>
    <span>
     <% Html.RenderAction("studentDetails", "home", new { @et = e }); %>
        </span>
    </div>
</div>
<%i++; } %>

Here my intension was to execute Renderction Student only once and Studentdetails should be multiple times.

But int value is always taking i =0 bec each time page is loading its considering 0 always.

Can anybody tell me how to do this?开发者_StackOverflow中文版


but int value is allways taking i =0 bec each time page is loading its considering 0 allways.

That's how it works. That's how pretty much all web platforms work. Every time your page code you're working a new instance of the object. Once a page request is fully rendered, anything used to build that request that you haven't explicitly saved somewhere like the Session is disposed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜