如何在Mvc中获取网格的数据键 [英] How Do I Get Datakey Of Grid In Mvc

查看:161
本文介绍了如何在Mvc中获取网格的数据键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像asp.net gridview一样,我想在MVC4中选择所选网格行的数据键,如果你使用的是数据表,那么它不会显示在网格

解决方案

中非常简单,您可以访问行绑定或行创建事件的ID列。



如果您使用的是普通网格,那么您可以使用ID列值作为带有控件的data-userID,点击某个按钮,你可以在jquery中以object.data('userID')的形式访问这个值

检查此链接是否有答案:



MVC WebGrid有datakey选项吗? | ASP.NET论坛 [ ^ ]



遗憾的是,Webgrid不支持Datakey选项。它必须是网址或隐藏字段的关键字。



祝你好运。


As like asp.net gridview i want to select datakey of selected row of grid in MVC4 which is not displayed in grid

解决方案

if you are using datatables then its very easy, you can access the ID columns on row-binding or row-creation events.

if you are using normal grid then you can use ID columns value as a data-userID with your controls and on clicking on some button you can access this value as object.data('userID') in jquery


Check this link for you answer :

does MVC WebGrid have datakey option? | The ASP.NET Forums[^]

Sadly Webgrid does not support Datakey option. It has to be eithter key to the url or hidden field.

Good luck.


这篇关于如何在Mvc中获取网格的数据键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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