我有一個GridView
即我填寫使用sqldatasource
我使用頁眉沒有問題排序在所有通過啓用AllowSorting="true"
允許的GridView排序ASP C#
然後我過濾此GridView
使用不同的控制器,我運行過濾功能下面使用DataTable
:
var mySqlConnection = //mySqlConnection
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
cmd = new SqlCommand("SPRlist_GetSPRCombine", mySqlConnection);
cmd.Parameters.AddWithValue("@SPRKaimrcNo", sprkaimrcno);
cmd.Parameters.AddWithValue("@SPRNo", sprno);
cmd.Parameters.AddWithValue("@DateOfRequest", dateofrequest);
cmd.Parameters.AddWithValue("@RequesterBadge", requesterbadge);
cmd.Parameters.AddWithValue("@DeptID", department);
cmd.Parameters.AddWithValue("@SPRStatus", sprstatus);
mySqlConnection.Open();
cmd.CommandType = CommandType.StoredProcedure;
da.SelectCommand = cmd;
da.Fill(dt);
我打電話通過控制器變量的函數,這讓我回確切的結果:
GridViewSPRlist.DataSourceID = "";
//Data Table Function Passing Controllers
GridViewSPRlist.DataBind();
的問題是:如果過濾GridView
我不能對它進行排序,我也得到了以下錯誤:
The data source does not support sorting. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NotSupportedException: The data source does not support sorting.
如何啓用排序的DataTable的數據源?
的可能的複製[排序的GridView綁定到數據表(http://stackoverflow.com/questions/3240252/sort-gridview-bound-to-datatable) –
重複與http://stackoverflow.com/questions/10776372/allow-sorting-by-column-gridview –
@TonyDong我已經檢查過它,並沒有爲我工作! –