views:

40

answers:

1
<%@ 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 allways taking i =0 bec each time page is loading its considering 0 allways..

can anybody tell me how to do this?

thanks

+2  A: 

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.

Joel Coehoorn
Then how to handle this type of things? thanks
kumar