首页 > 其他 > 详细

Week5(10月10日):国庆之后,让我们整装期待元旦吧

时间:2014-10-07 16:53:03      阅读:181      评论:0      收藏:0      [点我收藏+]

Part I:提问 

===========================

 1.要将“Hello, Admin",从控制器传递到视图,该如何操作?

(1)使用ViewData

(2)使用ViewBag

2.已知某学生类Student.cs,控制器中Index动作将学生传递给视图,请解释强类型传递的原理。

public ActionResult Index()
        {
            return View(db.Students.ToList());
        }
@model IEnumerable<tempPractice.Models.Student>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.StuNo)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Phone)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.StuNo)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Phone)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
}

</table>

 

 

Part II:Ch03 视图3

===========================

要点:

    2.知识点3-5:HTML辅助方法

 

Week5(10月10日):国庆之后,让我们整装期待元旦吧

原文:http://www.cnblogs.com/meetyy/p/4009389.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!