DataTableによるSpgridViewフィルタリングとソート
-
10-12-2019 - |
質問
私は、私がオンラインで見た記事から、彼らはObjectDataSourceなどを使用している記事からSpgridViewをフィルタリングと並べ替える必要があります。この場合のフィルタリングまたはソート?私はたくさん試してみました、そして今私のために働いています。
ありがとう
解決
フィルタリング
.
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);
参考文献
ページ区切りを持つSpgridView WebPartの作成、SharePointサイトのソート、ソート、フィルタリング機能