MVC2 Views 传值到Controller问题
专爆菜鸟 2013-04-19 04:03:53 先上代码
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcSMC.Models.PageData<MvcSMC.Models.Account>>" %>
第二段代码
<div class="div_search">
<% using (Html.BeginForm()) { %>
<table border="0" cellpadding="0" cellspacing="1">
<tr>
<td class="align_right">客户姓名:</td>
<td class="align_left search_filed">
<%: Html.TextBoxFor(m => m.PageIndex)%> <%--//MODEL传值应该是ACCOUNT表的--%> </td>
<td class="align_right">客户账号:</td>
<td class="align_left search_filed">
<%: Html.TextBoxFor(m => m.Count)%> </td>
<td class="align_center">
<input id="Button1" type="button" value="查询" />
</td>
</tr>
</table>
<% } %>
</div>
第三段代码
<% foreach (var item in Model.GetDate) { %>
<tr>
<td class="list_content_td">
<%: item.AccountId %>
</td>
<td class="list_content_td">
<%: item.AccountName %>
</td>
<td class="list_content_td">
<%: String.Format("{0:g}", item.AddTime) %>
</td>
<td class="list_content_td">
<%: item.EmailAddress %>
</td>
<td class="list_content_td">
<%: item.AccountNum %>
</td>
<td class="list_content_td">
<%: Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) %> |
<%: Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })%> |
<%: Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })%>
</td>
</tr>
<% } %>
请注意下蓝色字,红色获取的是PageDate的属性字段,需要传递的是Accpount的属性字段