Posts

Showing posts with the label MVCContribGrid

Donate

ASP.NET MVC Implementing MVCContribGrid CustomPagination<T> Class

Image
Out of boredom, I came upon a class named CustomPagination in MVCContrib that that implements IPagination , IEnumerable and other interfaces that you can customize your paging needs.Here's the class definition: namespace MvcContrib.Pagination { public class CustomPagination <T> : IPagination<T>, IPagination, IEnumerable<T>, IEnumerable { public CustomPagination(IEnumerable<T> dataSource, int pageNumber, int pageSize, int totalItems); public int FirstItem { get ; } public bool HasNextPage { get ; } public bool HasPreviousPage { get ; } public int LastItem { get ; } public int PageNumber { get ; } public int PageSize { get ; } public int TotalItems { get ; } public int TotalPages { get ; } public IEnumerator<T> GetEnumerator(); } } I found an article in this blog( http://lsd.luminis.eu ) on how to use the CustomPagination class that r

Pass GUID As Parameter To Action Using ASP.NET MVC ContribGrid

Hi, In a scenario where in you want to pass a GUID object to an Action Parameter, the parameter might contain a null value. Since Guid is not nullable, you can't simply just pass it to an action parameter because Action parameters require nullable and reference types. You might encounter an error like this: An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter Assuming you have an aspx view below: <div> <% Html.Grid(Model).Columns (c => { c.For(m => m.Price); c.For(m => m.ProductName); c.For(m => m.ProductID); c.For( "View Person" ).Named( "" ).Action(m => { %> <td> <%= Html.ActionLink( "View Person" , "ProductDetail" , "Home" , new { @id = m.ProductID.ToString() }) %> </td> <% }); %> <% }).Render(); %> </div> and an action

Donate