我需要基于DataTable的帮助过滤和排序SpGridView,从我在线看到的文章,它们使用ObjectDataSource等,但我将网格直接绑定到DataTable,是有没有关于如何实现的教程在这种情况下过滤或排序?我已经尝试了很多,现在为我工作。

感谢

有帮助吗?

解决方案

过滤

oGrid.AllowFiltering = true;
oGrid.FilterDataFields = "Title"; //tells the SPGridView what columns we want to be able to  filter on.
oGrid.FilteredDataSourcePropertyName = "FilterExpression";
oGrid.FilteredDataSourcePropertyFormat = "{1} like '{0}'"; //property provides the format for our filter expression in a SQL-like syntax.
.

排序

oGrid.AllowSorting = true;
oGrid.Sorting += new GridViewSortEventHandler(oGrid_Sorting);
void oGrid_Sorting(object sender, GridViewSortEventArgs e)
{
    // Call bind datatable function
    BindData();
}

// Also make sure when you are adding the columns you should define SortExpression
BoundField colTitle = new BoundField();
colTitle.DataField = "Title";
colTitle.HeaderText = "Title";
colTitle.SortExpression = "Title";
this.oGrid.Columns.Add(colTitle);
.

引用

Sp Gridview过滤在分享点2010

spgridview全部 - 分组,分页,过滤,排序

创建Spgridview webpart的分页,排序,在步骤方式中排序,过滤SharePoint站点的功能

许可以下: CC-BY-SA归因
scroll top