The current accepted answer is not the answer to your problem.
Enumerations don't seem to be sorted unless you specify a column name in the bind operation. I fixed this by providing all the necessary column names when binding my model to webgrid. The UserType property is an enumeration in this example.
var webgrid = new WebGrid(rowsPerPage: 25);
webgrid.Bind(Model, new[] { "FirstName", "MiddleName", "SurName", "UserType" });
var columns = webgrid.Columns(
webgrid.Column("FirstName", "Voornaam"),
webgrid.Column("MiddleName", "Tussenvoegsels"),
webgrid.Column("SurName", "Achternaam"),
webgrid.Column("UserType", "Type gebruiker"),
);
, , , :
<div id="grid">
@{
var grid = new WebGrid(canPage: true, rowsPerPage: Ctrl.PageSize, canSort: true, ajaxUpdateContainerId: "grid");
grid.Bind(Model.Events, new[] { "Type", "Source" }, rowCount: Model.TotalRecords, autoSortAndPage: false);
grid.Pager(WebGridPagerModes.All);
@grid.GetHtml(htmlAttributes: new { id="grid" },
columns: grid.Columns(
grid.Column("Type"),
grid.Column("Source"));
}
</div>