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]