Articles in this section
Category / Section

How to resolve routing issues in IIS for Grid datasource binding?

1 min read

Routing issues in Grid remote data-binding can be resolved by using Action method of Url Helper.

 

Solution               

When binding remote to Grid, routing problems may occur due to improper relative path. The proper relative path can be provided by using Action method of Url Helper.

Pass the action and controller name to Url.Action method in URL property of Grid DataSource and if the project is hosted in IIS under a virtual path then the parameter Request.Url.Scheme should be provided to recognize the virtual path while routing.

 

@(Html.EJ().Grid<OrdersView>("RemoteBinding")
        .Datasource(ds => ds.URL(Url.Action("GetDataSource", "Grid", null, Request.Url.Scheme)).Adaptor(AdaptorType.UrlAdaptor))
        .AllowPaging()
        .PageSettings(page => { page.PageSize(9); })
        .Columns(col =>
        {
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
            col.Field("CustomerID").HeaderText("Customer ID").Width(90).Add();
            col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(90).Add();
            col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add();
            col.Field("ShipCity").HeaderText("Ship City").Width(80).Add();
            col.Field("OrderDate").Format("{0:MM/dd/yyyy}").Width(80).TextAlign(TextAlign.Right).Add();
            col.Field("ShipCountry").HeaderText("Ship Country").Width(100).Add();
        })
    )

 

The following screenshot displays the Grid control hosted in IIS with virtual path MVCB.

Figure: Grid with remote data binding hosted in IIS

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied