本节讲一些基础性的东西
InBlock.gif <%: Html.ActionLink("修改""Edit"new { Controller="Movie",Action="Edit",id=item.ID})%> 
InBlock.gif                                | 
InBlock.gif                                <%: Html.ActionLink("明细""Details"new { Controller = "Movie", Action = "Details", id = item.ID })%> 
InBlock.gif                                | 
InBlock.gif                                <%: Html.ActionLink("删除""Delete"new { id=item.ID })%>
第一二行跨controller,传送数据。第三行不跨,就在当前的控制器找action。
InBlock.gif<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcApplication1.Models.Movie>>" %> 
InBlock.gif 
InBlock.gif<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"
InBlock.gif        Search 
InBlock.gif</asp:Content> 
InBlock.gif<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server"
InBlock.gif        <script language="javascript" type="text/javascript"
InBlock.gif                //        function isCheck() 
InBlock.gif                //        { 
InBlock.gif                //                var rbts = document.getElementsByName("Id"); 
InBlock.gif                //                for (var i = 0; i < rbts.length; i++) { 
InBlock.gif                //                        if (rbts[i].checked) { 
InBlock.gif                //                                return true; 
InBlock.gif                //                        } 
InBlock.gif                //                } 
InBlock.gif                //                alert("请选择一行数据"); 
InBlock.gif                //                return false; 
InBlock.gif                //        } 
InBlock.gif                function isCheck() { 
InBlock.gif                        var hfd = document.getElementById("hfdId"); 
InBlock.gif                        if (hfd.value == "") { 
InBlock.gif                                alert("请选择一行数据"); 
InBlock.gif                                return false
InBlock.gif                        } 
InBlock.gif                } 
InBlock.gif                function setValue(rbt) { 
InBlock.gif                        var hfd = document.getElementById("hfdId"); 
InBlock.gif 
InBlock.gif                        hfd.value = rbt.value; 
InBlock.gif                } 
InBlock.gif        </script> 
InBlock.gif</asp:Content> 
InBlock.gif<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"
InBlock.gif        <h2> 
InBlock.gif                Search</h2> 
InBlock.gif        <% using (Html.BeginForm("Edit""Movie", FormMethod.Get)) 
InBlock.gif             { %> 
InBlock.gif        <table> 
InBlock.gif                <tr> 
InBlock.gif                        <td colspan="4" style="text-align: right"
InBlock.gif                                <input type="submit" value="修改" onclick="return isCheck();" /> 
InBlock.gif                        </td> 
InBlock.gif                </tr> 
InBlock.gif                <tr> 
InBlock.gif                        <th> 
InBlock.gif                                选择 
InBlock.gif                        </th> 
InBlock.gif                        <th> 
InBlock.gif                                ID 
InBlock.gif                        </th> 
InBlock.gif                        <th> 
InBlock.gif                                Movie_Name 
InBlock.gif                        </th> 
InBlock.gif                        <th> 
InBlock.gif                                Realease_Date 
InBlock.gif                        </th> 
InBlock.gif                </tr> 
InBlock.gif                <% foreach (var item in Model) 
InBlock.gif                     { %> 
InBlock.gif                <tr> 
InBlock.gif                        <td> 
InBlock.gif                                <%: Html.RadioButton("Id", item.ID, new { onclick="setValue(this);"})%> 
InBlock.gif                        </td> 
InBlock.gif                        <td> 
InBlock.gif                                <%: item.ID%> 
InBlock.gif                        </td> 
InBlock.gif                        <td> 
InBlock.gif                                <%: item.Movie_Name%> 
InBlock.gif                        </td> 
InBlock.gif                        <td> 
InBlock.gif                                <%: String.Format("{0:g}", item.Realease_Date)%> 
InBlock.gif                        </td> 
InBlock.gif                </tr> 
InBlock.gif                <% } %> 
InBlock.gif        </table> 
InBlock.gif        <p> 
InBlock.gif                <%: Html.Hidden("hfdId") %> 
InBlock.gif        </p> 
InBlock.gif        <p> 
InBlock.gif                <%: Html.ActionLink("返回""Search""Test")%> 
InBlock.gif        </p> 
InBlock.gif        <%} %> 
InBlock.gif</asp:Content> 
这个界面实现根据选中的行,修改值。
修改页面为using (Html.BeginForm("Edit", "Movie", FormMethod.Get))所指定的action对应的页面
下面是一个datePick的例子
InBlock.gif<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcApplication1.Controllers.Movies>>" %> 
InBlock.gif 
InBlock.gif<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"
InBlock.gif</asp:Content> 
InBlock.gif<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server"
InBlock.gif        <link href="../../Scripts/DataPicker/css/ui.all.css" /> 
InBlock.gif        <script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script> 
InBlock.gif        <script src="../../Scripts/DataPicker/js/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script> 
InBlock.gif        <script src="../../Scripts/DataPicker/js/ui.datepicker-zh-CN.js" type="text/javascript"></script> 
InBlock.gif        <script src="../../Scripts/JS1/Common.js" type="text/javascript"></script> 
InBlock.gif        <script language="Javascript" type="text/javascript"
InBlock.gif                function setColor() { 
InBlock.gif                        var table1 = document.getElementById('table1'); 
InBlock.gif                        for (i = 0; i < table1.rows.length; i++) { 
InBlock.gif                                (i % 2 == 0) ? (table1.rows[i].className = "t1") : (table1.rows[i].className = "t2"); 
InBlock.gif                        } 
InBlock.gif                } 
InBlock.gif        </script> 
InBlock.gif        <script type="text/javascript"
InBlock.gif                $(function () { 
InBlock.gif 
InBlock.gif 
InBlock.gif                        $('#startTime').datepicker({ 
InBlock.gif                                changeMonth: true
InBlock.gif                                changeYear: true 
InBlock.gif                        }); 
InBlock.gif                        $('#endTime').datepicker({ 
InBlock.gif                                changeMonth: true
InBlock.gif                                changeYear: true 
InBlock.gif                        }); 
InBlock.gif                }); 
InBlock.gif        </script> 
InBlock.gif</asp:Content> 
InBlock.gif<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"
InBlock.gif        <h2> 
InBlock.gif                ShowDB</h2> 
InBlock.gif        <% using (Html.BeginForm("Search""Test")) 
InBlock.gif             {%> 
InBlock.gif        <table id="table1"
InBlock.gif                <tr> 
InBlock.gif                        <td colspan="2"
InBlock.gif                                按时间从 
InBlock.gif                        </td> 
InBlock.gif                        <td colspan="2"
InBlock.gif                                <input type="text" id="startTime" name="startTime" />  至 <input type="text" 
InBlock.gif                                        id="endTime" name="endTime" /> 
InBlock.gif                                <input type="submit" id="btnSearch" value="查询" /> 
InBlock.gif                        </td> 
InBlock.gif                </tr> 
InBlock.gif                <tr> 
InBlock.gif                        <th> 
InBlock.gif                        </th> 
InBlock.gif                        <th> 
InBlock.gif                                ID 
InBlock.gif                        </th> 
InBlock.gif                        <th> 
InBlock.gif                                MoviewName 
InBlock.gif                        </th> 
InBlock.gif                        <th> 
InBlock.gif                                RealeaseDate 
InBlock.gif                        </th> 
InBlock.gif                </tr> 
InBlock.gif                <% foreach (var item in Model) 
InBlock.gif                     { %> 
InBlock.gif                <tr onmouseover="SetNewColor(this);" onmouseout="SetOldColor(this);" style="cursor: hand"
InBlock.gif                        <td> 
InBlock.gif                                <%: item.ID%> 
InBlock.gif                        </td> 
InBlock.gif                        <td> 
InBlock.gif                                <%: item.Movie_Name%> 
InBlock.gif                        </td> 
InBlock.gif                        <td> 
InBlock.gif                                <%: item.Realease_Date%> 
InBlock.gif                        </td> 
InBlock.gif                        <td style="width: 100%"
InBlock.gif                                <%: Html.ActionLink("Edit""Edit"new { id = item.ID })%> 
InBlock.gif                                | 
InBlock.gif                                <%: Html.ActionLink("Details""Details"new { id = item.ID })%> 
InBlock.gif                                | 
InBlock.gif                                <%: Html.ActionLink("Delete""Delete"new { id = item.ID })%> 
InBlock.gif                        </td> 
InBlock.gif                </tr> 
InBlock.gif                <% } %> 
InBlock.gif        </table> 
InBlock.gif        <p> 
InBlock.gif                <%: Html.ActionLink("Create New""Create")%> 
InBlock.gif        </p> 
InBlock.gif        <div> 
InBlock.gif        </div> 
InBlock.gif        <%} %> 
InBlock.gif</asp:Content> 
效果如下,using (Html.BeginForm("Search", "Test", FormMethod.Get, new { autocomplete="off"}))这句用来限制自动完成
点击文本框,弹出如下
控制器代码
InBlock.gif public ActionResult Search() 
InBlock.gif                { 
InBlock.gif                        ViewData.Model = m1.Movies.ToList(); 
InBlock.gif                        return View(); 
InBlock.gif                } 
InBlock.gif                [HttpPost] 
InBlock.gif                public ActionResult Search(FormCollection fc) 
InBlock.gif                { 
InBlock.gif                        DateTime startTime = DateTime.Parse(fc["startTime"].ToString()); 
InBlock.gif                        DateTime endTime = DateTime.Parse(Request.Form["endTime"].ToString() 
InBlock.gif                                ); 
InBlock.gif                     
InBlock.gif                        var Result = from m in m1.Movies where m.Realease_Date >= startTime && m.Realease_Date <= endTime select m; 
InBlock.gif                        return View(Result); 
InBlock.gif                }