none
请教,mvc中把页面转化成部分视图后,原来页面从action取得数据,现在从那里取? RRS feed

  • 问题

  • 页面代码

    @{
        Layout = null;
    }
    <!DOCTYPE html>
    <html>
    <head>
        <title>操作票信息</title>
        <style type="text/css">
            body
            {
                margin: 0px;
                            font: 80% "Trebuchet MS" , sans-serif;

            }
           
            table, td
            {
                border-color: Black;
            }
        </style>
    </head>
    <body>
        <div>
            <table border="1" cellpadding="0" cellspacing="0" style="width: 100%; border-collapse: collapse;">
                <tr>
                    <td>
                        操作票编号:
                    </td>
                    <td>
                        20100506026
                    </td>
                    <td>
                        操作票状态:
                    </td>
                    <td>
                        批准 新票
                    </td>
                </tr>
                <tr>
                    <td>
                        提票人:
                    </td>
                    <td>
                        罗洪超/远程
                    </td>
                    <td>
                        申请时间:
                    </td>
                    <td>
                        @Html.DropDownList("year")年
                        @Html.DropDownList("month")月
                        @Html.DropDownList("day")日
                        @Html.DropDownList("hour")时
                        @Html.DropDownList("minute")分
                    </td>
                </tr>
                <tr>
                    <td>
                        申请人
                    </td>
                    <td colspan="3">
                        地区:@Html.DropDownList("area")
                        单位:@Html.DropDownList("unit")
                        申请人:@Html.DropDownList("shenqingren")
                    </td>
                </tr>
                <tr>
                    <td>
                        设备
                    </td>
                    <td colspan="3">
                        <textarea id="SheBei" style="width: 99%; height: 100%; border: 0px;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        工作内容
                    </td>
                    <td colspan="3">
                        <textarea id="GongZuoNeiRong" style="width: 99%; height: 100%; border: 0px;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        申请
                    </td>
                    <td colspan="3">
                        20110411至20110418
                    </td>
                </tr>
                <tr>
                    <td>
                        批准
                    </td>
                    <td colspan="3">
                        20110411至20110418
                    </td>
                </tr>
                <tr>
                    <td>
                        延期
                    </td>
                    <td colspan="3">
                        20110411至20110418
                    </td>
                </tr>
            </table>
        </div>
    </body>
    </html>

     

    action代码

            /// <summary>
            /// 操作票信息
            /// </summary>
            /// <returns></returns>
            public ActionResult CaoZuoPiaoXinXi()
            {
                //年
                var year = new List<SelectListItem>()
                {
                    (new SelectListItem() {Text = "2000", Value = "2000"}),
                    (new SelectListItem() {Text = "2001", Value = "2001"}),
                    (new SelectListItem() {Text = "2002", Value = "2002"})
                };

                //月
                var month = new List<SelectListItem>()
                {
                    (new SelectListItem() {Text = "1", Value = "1"}),
                    (new SelectListItem() {Text = "2", Value = "2"}),
                    (new SelectListItem() {Text = "3", Value = "3"})
                };

                //天
                var day = new List<SelectListItem>()
                {
                    (new SelectListItem() {Text = "1", Value = "1"}),
                    (new SelectListItem() {Text = "2", Value = "2"}),
                    (new SelectListItem() {Text = "3", Value = "3"})
                };

                //时
                var hour = new List<SelectListItem>()
                {
                    (new SelectListItem() {Text = "1", Value = "1"}),
                    (new SelectListItem() {Text = "2", Value = "2"}),
                    (new SelectListItem() {Text = "3", Value = "3"})
                };

                //分
                var minute = new List<SelectListItem>()
                {
                    (new SelectListItem() {Text = "1", Value = "1"}),
                    (new SelectListItem() {Text = "2", Value = "2"}),
                    (new SelectListItem() {Text = "3", Value = "3"})
                };


                //地区
                var area = new List<SelectListItem>()
                {
                    (new SelectListItem() {Text = "地区一", Value = "1"}),
                    (new SelectListItem() {Text = "地区二", Value = "2"}),
                    (new SelectListItem() {Text = "地区三", Value = "3"})
                };

                //单位
                var unit = new List<SelectListItem>()
                {
                    (new SelectListItem() {Text = "单位一", Value = "1"}),
                    (new SelectListItem() {Text = "单位二", Value = "2"}),
                    (new SelectListItem() {Text = "单位三", Value = "3"})
                };

                //申请人
                var shenqingren = new List<SelectListItem>()
                {
                    (new SelectListItem() {Text = "张三", Value = "1"}),
                    (new SelectListItem() {Text = "李四", Value = "2"}),
                    (new SelectListItem() {Text = "王五", Value = "3"})
                };

                ViewData["year"] = year;
                ViewData["month"] = month;
                ViewData["day"] = day;
                ViewData["hour"] = hour;
                ViewData["minute"] = minute;
                ViewData["area"] = area;
                ViewData["unit"] = unit;
                ViewData["shenqingren"] = shenqingren;


                return View();
            }

     

    转换成部分视图后,会报错,因为下拉列表找不到数据了

    • 已移动 LeoTang 2011年4月28日 3:41 (发件人:Web, IE 9相关讨论 (IIS,IE8等))
    2011年4月26日 3:19

答案