My first MSDN Magazine article is up: Get the Most out of WebGrid in ASP.NET MVC. So, if you want to find out how to make the WebGrid component from WebMatrix fit in with ASP.NET MVC then take a peek…. http://msdn.microsoft.com/en-us/magazine/hh288075.aspx.
Thanks to Carl Nolan and Simon Ince for reviewing the article :-)
**UPDATE - the helpers are now up on NuGet: http://blogs.msdn.com/b/stuartleeks/archive/2012/01/24/webgrid-extensions-on-nuget.aspx **
I read your article, it was well written and very informative.
Good job! Congratulations on your first publication. Many more to follow I hope.
Good article, but what is the SafeCast method that you are using? I am guessing some extension method, but I haven't found any such method in the framework, and a Google search provides numerous hits, none of which appear to be an exact match.
Hi Graeme,
the SafeCast was a little extension method that slightly simplified the code listing by removing a null check. It's in the code download under Infrastructure\EnumerableExt
public static class EnumerableExtensions
{
public static IEnumerable<TTarget> SafeCast<TTarget>(this IEnumerable source)
return source == null ? null : source.Cast<TTarget>();
}
- Stuart
Thanks Stuart. Somehow I managed to completely miss the fact that there was a download.
Nice Article.
Can you please explain how to edit WebGrid Column values.
i.e i want user insert some values in our Gridview and on basis of values i have to display some calculation in gridview.
@Bhargav, to enable adding data you would need to render a set of input elements. You could then either add the data to the table in javascript (including performing the calculations), or you could send the data up to the server and retrieve the update to the grid (with calculations performed on the server)
Great article Stuart. Is there a way to use WebGrid (or any other equivalent control is ASP.Net MVC) to select multiple rows ?
Thanks
Siva
@Siva, you could render the grid inside a <form> and render a custom column in the grid that is a checkbox. Submitting the form would then include any checkboxes that were selected. This wouldn't work across pages in the grid, but aside from that should be a relatively simple solution