i am trying to sort a DataSet as desired:
protected void GridView1_Sorting1(object sender, GridViewSortEventArgs e)
{
DataSet data = (DataSet)GridView1.DataSource;
//sort data by e.SortExpressions
//data.Sort that doesn't work
//data.Tables[0].Sort that doesn't work
DataView view = data.Tables[0].DefaultView;
view.Sort = e.SortExpression;
GridView1.DataBind();
}
Do not try and sort the DataSet - that's impossible. Instead, only try to realize the truth...
...you sort the DataView instead the DataTable inside the DataSet:
protected void GridView1_Sorting1(object sender, GridViewSortEventArgs e)
{
DataSet dataSet = (DataSet)GridView1.DataSource;
DataTable dataTable = (DataTable)dataSet.Tables[0];
DataView dataView = dataTable.DefaultView;
dataView.Sort = "TransactionNumber";
GridView1.DataBind();
}
Except the grid doesn't come out sorted by the TransactionNumber column in the Data*.
Is there some view.RunSort() method that needs to be called before sorting "takes effect"?