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);

  •    _LoadGrid being created under the “Shared” folder
  •    Model.CountryDetail is model information being passed as parameter to the partial view

PartialView (_LoadGrid)

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

OUTPUT

LoadGridinPartialView

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