2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > View和View的参数传递

View和View的参数传递

时间:2024-07-24 06:45:25

相关推荐

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>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。