Data View Sorting Question
Hello and thanks for taking a moment to read this message. I am using a DataView to sort on the columns of a datagrid.(Doing this from within the SQL turned out to be more trouble than it was worth in this particular case.) The problem is that my DataGrid also allows paging.
I am trying to figure out how to sort data on a page by page basis.( example, if I'm on page 3 of my data grid, I want to click on a grid column and see only they sorted data which was on page 3) Currently, when I click a column heading, it shows me the data at the very top of the result set. (again, not what I want if I was on page 3) Itr should be noted that I am not doing custom paging in this case. Below is my snippet of Codebehind that runs when I click a column heading. Any help would be greatly appreciated.Thanks,
Jason
public void Grid_Sort( Object source,DataGridSortCommandEventArgs e)
{
//Get the entire result Set
ActionLinkSupport alxr = new ActionLinkSupport();
DataSet ds = alxr.GetInventoryDataForActionLink(Convert.ToInt32 (drpRetailer.SelectedValue),(drpDisplayName.Select edItem).ToString(),(drpDisplayPopItemDescription.S electedItem).ToString(),Convert.ToInt32(ddaction.S electedValue),e.SortExpression.ToString());
//Use a Data View to be able to sort on the columns will sort on e.SortExpression
DataGrid2.DataSource = new DataView(ds.Tables["tblInventoryItems"],string.Empty,e.SortExpression.ToString(),DataView RowState.CurrentRows);
DataGrid2.DataBind();
}
|