Click here to Skip to main content
15,898,897 members

Comments by Sireesha E (Top 2 by date)

Sireesha E 26-Nov-15 6:27am View    
Model.SelectedServer.Services is null, It will load only after the selecting the item from dropdown.

I have tried with If statement like @If(Model.SelectedServer.Services!=null){}

But after selecting dropdown, I am calling a jQuery function (from which onSuccess, It will get result from an action method), its not applied to the Webgrid

success: function (result) {
$("#GridTable").html(result);
},

result is in the form of list (returning JsonResult from controller).
Sireesha E 26-Nov-15 5:27am View    
@Html.DropDownListFor(r => r.servers, new SelectList(Enumerable.Empty<SelectListItem>(), "ServerID", "ServerName", Model.SelectedServerID), "Select", new { @id = "ServersList", @onchange = "GetServices()" })

@{
var grid = new WebGrid(Model.SelectedServer.Services, rowsPerPage: 5, ajaxUpdateContainerId: "gridcontent");
}
<div id="gridcontent">

@grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: grid.Columns(grid.Column("ServiceName", "DisplayName"),
grid.Column("Status", "DisplayName"),


Here, in Webgrid Source is null when the page loads, After selecting a value from Dropdownlist, Model.SelectedServer.Services loads.
So how to get rid of this null exception while page loads