[webgrid] – selecterow - (Get Selected Row from ASP.NET MVC 3 WebGrid)
Get Selected Row from ASP.NET MVC 3 WebGrid
Abstract: The following article demonstrates how to get the selected row from the ASP.NET MVC 3 WebGrid and what to do to display data.
Every website has to display data and every website has a Grid control. In ASP.NET MVC 3 there’s the WebGrid, which is part of the Microsoft Web Helpers library. This can be downloaded through NuGet (formerly NuPack). NuGet is a free open source package manager that makes it easy for you to find, install, and use .NET libraries in your projects. One piece of functionality that is critical is reacting when the user selects an item in the WebGrid. This article will focus on finding out which row was selected, but also how to find out more about the data that is selected.
Before moving on, you need to download ASP.NET MVC 3. Click here to download and install them using the Microsoft Web Platform Installer.
Open studio 2010 and create a new ASP.NET MVC 3 Web Application (Razor) project. To focus on the answer, I’ve got a simple model as seen below.
Using the WebGrid, it’s easy to display this data to the user.
The first column is the key to making this work. @item.GetSelectLink outputs a HTML anchor tag with the row selected. This is passed as aQueryString, and the name of the QueryString is set by the selectionFieldName property set on the grid.
To find out what row is selected is just as easy. The WebGrid has a property called SelectedRow. This sets a reference to a GridViewRow object that represents the selected row in the control. When you combine this with the HasSelection property, you can get the selected row like this.
I’ve created a partial view called _Person.cshtml. The file begins with an underscore (_) because I don’t want this file called directly from the web. The second parameter is the data being passed into the partial view. The data in this instance is the selected row.
The partial view has then got access to all the data in the selected row. Nice and easy. Thanks Microsoft!!
The entire source code of this article can be downloaded over here
[webgrid] – selecterow - (Get Selected Row from ASP.NET MVC 3 WebGrid)的更多相关文章
- ASP.NET MVC 的 WebGrid 的 6 个重要技巧 【已翻译100%】
ASP.NET MVC 中 WebGrid 的 6 个重要技巧 https://www.oschina.net/translate/webgrid-in-asp-net-mvc-important-t ...
- The Three Models of ASP.NET MVC Apps
12 June 2012 by Dino Esposito by Dino Esposito We've inherited from the original MVC pattern a ra ...
- asp.net mvc 学习资料
ASP.NET MVC 的 WebGrid 的 6 个重要技巧 http://www.oschina.net/translate/webgrid-in-asp-net-mvc-important-ti ...
- 在 ASP.NET MVC 中充分利用 WebGrid (microsoft 官方示例)
在 ASP.NET MVC 中充分利用 WebGrid https://msdn.microsoft.com/zh-cn/magazine/hh288075.aspx Stuart Leeks 下载代 ...
- ASP.NET MVC WebGrid – Performing true AJAX pagination and sorting 【转】
ASP.NET MVC WebGrid – Performing true AJAX pagination and sorting FEBRUARY 27, 2012 14 COMMENTS WebG ...
- ASP.NET MVC搭建项目后台UI框架—6、客户管理(添加、修改、查询、分页)
目录 ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NE ...
- ASP.NET MVC搭建项目后台UI框架—7、统计报表
ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NET M ...
- ASP.NET MVC搭建项目后台UI框架—8、将View中选择的数据行中的部分数据传入到Controller中
目录 ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NE ...
- jQuery DataTables and ASP.NET MVC Integration
part 1 : http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Pa ...
随机推荐
- Java追加文件内容的三种方法
import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io. ...
- C# String.Format格式说明
C#格式化数值结果表 字符 说明 示例 输出 C 货币 string.Format("{0:C3}", 2) $2.000 D 十进制 string.Format("{0 ...
- jquery $.each 和for怎么跳出循环终止本次循环
1.for循环中我们使用continue:终止本次循环计入下一个循环,使用break终止整个循环. 2.而在jquery中 $.each则对应的使用return true 和return false. ...
- OPENGGL深度测试
深度测试是为了解决那些在绘图过程中本应该被隐藏的面结果却出现了,例如: 绘图代码中先绘制了一个一个近处的立方体,后绘制了一个远处的立方体,结果在绘制过程中,远处的立方体总是在近处的立方体后绘制,所以在 ...
- crontab 命令
1. crontab 可以在shell里面设置一些定时任务 格式 30 * * * * nohup sh /data/admin/adsprecise/sources/providers.sh mjo ...
- Android异步加载
一.为什么要使用异步加载? 1.Android是单线程模型 2.耗时操作阻碍UI线程 二.异步加载最常用的两种方式 1.多线程.线程池 2.AsyncTask 三.实现ListView图文混排 3-1 ...
- Nginx research, nginx module development
catalog . 初探nginx架构 . handler模块 . Nginx编译.安装.配置 . Hello World模块开发 1. 初探nginx架构 nginx在启动后,在unix系统中会以d ...
- 几个pointer
[备份]了解initramfs,越往深处走觉着需要了解的东西越多,所以干脆回来,从实际系统的实现开始寻迹.在学习的这个系统中,里面用了busybox,实现的系统可谓精简之又精简.早上主要学习了root ...
- C#位操作与枚举的应用
看到代码里有用位操作来判断条件的,以前没有这么用过,做个笔记: int add = 2; int modify = 4; int delete = 8; Console.WriteLine((add ...
- (转载)最长递增子序列 O(NlogN)算法
原博文:传送门 最长递增子序列(Longest Increasing Subsequence) 下面我们简记为 LIS. 定义d[k]:长度为k的上升子序列的最末元素,若有多个长度为k的上升子序列,则 ...