update your class with this classes in Model
public class UserDetail
{
public string UserLastName { get; set; }
public string UserEmail { get; set; }
public string UserRole { get; set; }
}
public class UserAccount
{
public IEnumerable<userdetail> _User { get; set; }
public IEnumerable<selectlistitem> UserRoles { get; set; }
}
cshtml file (view)
@model CodeProject.Models.UserAccount
@{
ViewBag.Title = "Users";
}
Users
@{
var grid = new WebGrid(Model._User, canPage: true, rowsPerPage: 5, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridContent");
grid.Pager(WebGridPagerModes.NextPrevious);
@grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: grid.Columns(
grid.Column("UserLastName", " Last Name"),
grid.Column("UserEmail", "Email Id", style: "description"),
grid.Column("UserRole", "UserRole"),
grid.Column("UserRoles", format: @item => Html.DropDownListFor(m => Model.UserRoles, Model.UserRoles, new { style = "width: 150px; background-color:gray" }))
))
}
Shahid Husain
SSE