public static SortUsers ( List |
||
users | List |
|
sortExpression | string | |
sortDirection | SortDirection, | |
Результат | IEnumerable |
protected void UsersGridView_Sorting(object sender, GridViewSortEventArgs e) { SortDirection sortDirection = SortingUtility.GetSortDirection(ViewState); ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR] = sortDirection; ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR] = e.SortExpression; List <CarServiceUser> users = GetUsers(); IEnumerable <CarServiceUser> sortedUsers = SortingUtility.SortUsers(users, e.SortExpression, sortDirection); BindUsersGrid(sortedUsers); }
private void BindUsersGrid() { object sortDirectionObj = ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR]; object sortExpressionObj = ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR]; List <CarServiceUser> users = GetUsers(); IEnumerable <CarServiceUser> sortedUsers; if (sortDirectionObj != null && sortExpressionObj != null) { sortedUsers = SortingUtility.SortUsers(users, sortExpressionObj.ToString(), (SortDirection)sortDirectionObj); } else { ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR] = SortDirection.Ascending; ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR] = CarServiceConstants.USER_NAME_SORT_EXPRESSION; sortedUsers = SortingUtility.SortUsers(users, CarServiceConstants.USER_NAME_SORT_EXPRESSION, SortDirection.Ascending); } BindUsersGrid(sortedUsers); }