EDN Admin
Well-known member
The past six articles in this series have looked at how to display a grid of data in an ASP.NET MVC application and how to implement features like sorting, paging,
and filtering. In each of these past six tutorials we were responsible for generating the rendered markup for the grid. Our Views included the
tags, the
elements for the header row, and a
loop that emitted a series of
elements for each row to display in the grid. While this approach certainly works, it does lead to a bit of repetition and inflates the size
of our Views.
The ASP.NET MVC framework includes an http://msdn.microsoft.com/en-us/library/system.web.mvc.htmlhelper.aspx
class that adds support
for rendering HTML elements in a View. An instance of this class is available through the
object, and is often used in a View to create action links
(
), textboxes (
), and other HTML content. Such content could certainly be created by writing the markup by hand
in the View; however, the
makes things easier by offering methods that emit common markup patterns. You can even
http://www.asp.net/mvc/tutorials/creating-custom-html-helpers-cs create your own custom HTML Helpers by adding
http://www.4guysfromrolla.com/articles/120507-1.aspx extension methods to the
class.
http://mvccontrib.codeplex.com/ MvcContrib is a popular, open source project that adds various functionality to the ASP.NET MVC framework. This includes
a very versatile http://mvccontrib.codeplex.com/wikipage?title=Grid Grid HTML Helper that provides a strongly-typed way to construct a grid in your
Views. Using MvcContribs Grid HTML Helper you can ditch the
,
, and
markup, and instead use
syntax like
. This article looks at using the MvcContrib Grid to display a grid of data in an ASP.NET MVC application. A future installment
will show how to configure the MvcContrib Grid to support both sorting and paging. Read on to learn more!
http://www.4guysfromrolla.com/articles/031611-1.aspx" class="readmore Read More >
View the full article
and filtering. In each of these past six tutorials we were responsible for generating the rendered markup for the grid. Our Views included the
Code:
<table>
Code:
<th>
Code:
foreach
Code:
<td>
of our Views.
The ASP.NET MVC framework includes an http://msdn.microsoft.com/en-us/library/system.web.mvc.htmlhelper.aspx
Code:
HtmlHelper
for rendering HTML elements in a View. An instance of this class is available through the
Code:
Html
(
Code:
Html.ActionLink
Code:
Html.TextBoxFor
in the View; however, the
Code:
HtmlHelper
http://www.asp.net/mvc/tutorials/creating-custom-html-helpers-cs create your own custom HTML Helpers by adding
http://www.4guysfromrolla.com/articles/120507-1.aspx extension methods to the
Code:
HtmlHelper
http://mvccontrib.codeplex.com/ MvcContrib is a popular, open source project that adds various functionality to the ASP.NET MVC framework. This includes
a very versatile http://mvccontrib.codeplex.com/wikipage?title=Grid Grid HTML Helper that provides a strongly-typed way to construct a grid in your
Views. Using MvcContribs Grid HTML Helper you can ditch the
Code:
<table>
Code:
<tr>
Code:
<td>
syntax like
Code:
Html.Grid(...)
will show how to configure the MvcContrib Grid to support both sorting and paging. Read on to learn more!
http://www.4guysfromrolla.com/articles/031611-1.aspx" class="readmore Read More >
View the full article