View和View的参数传递

View和View的参数传递


          在做ITOO的过程中,遇到了一个问题,就是页面和页面之间跳转参数传递的问题。

          这里前台使用的是easyUI的组件,第一个页面查看考生登录情况,其中有一个详情,点击之后,会跳转到第二个页面。

          第二个页面需要第一个页面的一些参数,你所选的该行的各个参数,考试、考场、考试日期和时间等等,查询并显示该场考试,这个考场的考生详细信息。

          第一个页面


          第二个页面


          这里在第一个View中使用的js,通过调用Controller中的一个方法,把第一个页面中的参数传到Controller中,具体代码如下:

<span style="font-size:24px;"><script type="text/javascript">
        //在"操作"一列中添加超链接.-编辑考核项目
        function rowformater(value, row, index) {
            return '<a href="/Monitore/MonitoreDetails?ExamID=' + row.ExamID + '&ExamPlaceID=' + row.ExamPlaceID + '&StartDate=' + row.StartDate + '&StartTime=' + row.StartTime + '">详情</a>'
            return;
        }
    </script></span>

          然后,在Controller中写一个方法用来接收传递过来的参数,再返回到第二个页面,这里使用的是ViewData。

<span style="font-size:24px;">public ActionResult MonitoreDetails()
        {
            //从第一个页面得到相关的参数,传给第二个页面
            string ExamID = Request.QueryString["ExamID"];
            string ExamPlaceID = Request.QueryString["ExamPlaceID"];
            string StartDate = Request.QueryString["StartDate"];
            string StartTime = Request.QueryString["StartTime"];
            ViewData["ExamID"] = ExamID;
            ViewData["ExamPlaceID"] = ExamPlaceID;          
            ViewData["StartDate"] = StartDate;
            ViewData["StartTime"] = StartTime;
            return View();
        }</span>

          最后,就是第二个页面接收这些参数,通过这些参数去查询数据库,得到想要的信息显示在表格中。

<span style="font-size:24px;"><table id="Chapter1" title="考生登录情况" class="easyui-datagrid" style="width:1160px; height: 400px;"  
                   
       idfield="itemid" pagination="true" data-options="rownumbers:true,url:'/Monitore/QueryMonitoreDetails?ExamID=@ViewData["ExamID"]&ExamPlaceID=@ViewData["ExamPlaceID"]&StartDate=@ViewData["StartDate"]&StartTime=@ViewData["StartTime"]',pageSize:5, pageList:[10,20,30,40],method:'get',toolbar:'#tb',striped:true" fitcolumns="true">
            <thead>
                <tr>
                    <th data-options="field:'StudentNo',width:100">学号</th>
                    <th data-options="field:'StudentName',width:100">姓名</th>
                    <th data-options="field:'State',width:100">状态</th>
                    @*<th data-options="field:'IP',width:100">IP</th>*@
                    <th data-options="field:'Colleage',width:100">学院</th>
                    <th data-options="field:'Major',width:100">专业</th>
                </tr>
            </thead>
        </table>
</span>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值