1

I have a gridview that on button click binds to a dataset, which in itself is populated by a stored procedure. I am just wondering if there is a simple way to apply sorting to the gridview without having to change any sql?

4

2 回答 2

1

您可以在任何临时数据表中获取存储过程值,然后对数据表数据应用排序并绑定到 gridview 。

于 2013-04-11T11:22:58.707 回答
0
 protected void radgvData_SortCommand(object sender, GridSortCommandEventArgs e)
        {
            GridTableView tableView = e.Item.OwnerTableView;
            e.Canceled = true;
            GridSortExpression expression = new GridSortExpression();
            expression.FieldName = e.SortExpression;
            if (tableView.SortExpressions.Count == 0 || tableView.SortExpressions[0].FieldName != e.SortExpression)
                expression.SortOrder = GridSortOrder.Descending;
            else if (tableView.SortExpressions[0].SortOrder == GridSortOrder.Descending)
                expression.SortOrder = GridSortOrder.Ascending;
            else if (tableView.SortExpressions[0].SortOrder == GridSortOrder.Ascending)
                expression.SortOrder = GridSortOrder.Descending;
            tableView.SortExpressions.AddSortExpression(expression);
            radgvData.Rebind();
        }

试试这个代码进行排序......

于 2013-04-11T11:23:23.860 回答