Site icon Dotnet Helpers

How to use WebGrid from PartialView using Razor

WebGrid is used to display the data with paging and sorting. In this article, we will discuss about how to load the data to webgrid and would like to explore how can to use default paging and sorting.

Controller

Let we create simple controller which will return the UserDetailModel to the view. From the view we can bind the WebGrid using the model data.

View

From the below code, just passing the model data to the partial view for loading WebGrid.

Note :

   From Html.RenderPartial(“_LoadGrid”, Model.CountryDetail);

PartialView (_LoadGrid)

_LoadGrid Partial view bind the WebGrid by receiving model data from the view.

OUTPUT

[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

Exit mobile version