如何将ID从一个视图传递到不同的视图 [英] how to pass an id from one view to different views

查看:106
本文介绍了如何将ID从一个视图传递到不同的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET MVC3.
我有3个意见
1.网格视图
2.列表视图
3.tab视图
我的要求是,当我单击网格的选定行时,id值必须传递到选项卡以及列表"视图.
我要显示的是,取决于网格上选择的值,当我单击选项卡时,列表视图必须根据网格中选择的ID显示记录.

您能告诉我如何传递此id值吗? br/>
1-在网址上输入ID.这意味着您的映射包括一个变量,该变量可以是可选的,并且该id传递到控制器中并用于读取显示的数据
2-读取后将其放入会话中

选项1更好,尤​​其是因为它意味着用户可以为页面添加书签,并且以后可以再次使用.


hi, I am using ASP.NET MVC3.
I have three views
1.Grid view
2.List View
3.tab View
My requirement is that,when i click on the selected row of the grid that id value has to pass to the tab as well as List view.
what i want to display is that depending upon on the value selected on the grid,when i click on the tab ,the list view has to display the records depending upon the id selected in the grid.

can u tell me how to pass this id value.

解决方案

There''s two ways of doing this, and this is true no matter what platform you use.

1 - put the id on the URL. That means your mapping includes a variable, that may be optional, and that id is passed in to the controller and used to read the data that is shown
2 - put it in the session once it''s been read

Option 1 is better, not least because it means users can bookmark a page and it will work again later on.


这篇关于如何将ID从一个视图传递到不同的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆