asp.net mvc两种传值(数据)方式(viewdata/mode)
SatngDateDataContext stdate = new SatngDateDataContext();
public ActionResult Index()
{
List<mmleave> mm = new List<mmleave>();
mm = stdate.mmleave.OrderByDescending(d => d.id>6).ToList();
ViewData["Message"] = mm;
return View(mm);
}
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<SaTngWebSite.Models.mmleave>>" %>
<h2><%foreach (var item in ViewData["Message"] as List<SaTngWebSite.Models.mmleave>)%>
<%{%>
<%=item.lname %>
<%} %></h2>
<p
</p>
<%foreach (var item in Model)%>
<%{%>
<%=item.ldates %>
<% } %>
</asp:Content>
public ActionResult Index()
{
List<mmleave> mm = new List<mmleave>();
mm = stdate.mmleave.OrderByDescending(d => d.id>6).ToList();
ViewData["Message"] = mm;
return View(mm);
}
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<SaTngWebSite.Models.mmleave>>" %>
<h2><%foreach (var item in ViewData["Message"] as List<SaTngWebSite.Models.mmleave>)%>
<%{%>
<%=item.lname %>
<%} %></h2>
<p
</p>
<%foreach (var item in Model)%>
<%{%>
<%=item.ldates %>
<% } %>
</asp:Content>