Sorting a datagrid without using a DataSet

  • Thread starter Thread starter Patrick Delifer
  • Start date Start date
P

Patrick Delifer

Hi,
Does anyone know if I can sort a DataGrid without using a dataset?

I am using an ArrayList to Databind in my datagrid. The ArrayList is
returned from a server object(that queries the DB).

All the exAamples I see on the net use a dataset. Is there any other way
of doing it? Can I use a DataView object without a Dataset?

Thanks.
Patrick
 
Can you not just sort the ArrayList before binding ?
Maybe the server object should have a SortBy property ?
A
 
Actually, it does not matter how you create your dataview, or datatable that
binds to the datagrid. You just need to sort those objects upon clicking
sort (by adding an event handler)

myDataGrid.SortCommand += new
DataGridSortCommandEventHandler(myDataGrid_Sort);

private void myDataGrid_Sort(object source, DataGridSortCommandEventArgs e)
{
// Create your Data table here
// You can sort it as you create it

// Bind your dataview/datatable here
myDataGrid.DataSource = myDataTable;
myDataGrid.DataBind();
}
 
HI Andrew,

yes I can sort the ArrayList (I can do it in my stored procedure) but
then I want the user to be able to sort using different header columns
(i.e Name, Address, Status,etc .
 
Turn on "allow sorting" on the grid, user can click on a column to sort, behind each column you've assigned "sortexpression", in OnSortCommand (vb speak) use sortexpression to decide how to sort the arraylist, and then rebind the arraylist to the datagrid. I just tried it with a trivial example, but it worked fine

----- Patrick Delifer wrote: ----


HI Andrew

yes I can sort the ArrayList (I can do it in my stored procedure) bu
then I want the user to be able to sort using different header column
(i.e Name, Address, Status,etc


*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it
 
Back
Top