|
| sorting a dataset |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.framework.adonet.
| Scott Bansfield |
| GOOD ANSWER |
I have a quick question about sorting a dataset. I have created a query: Select top 10 * from authors I have put the results of this query into a dataset and bound that to a datagrid. I have also enabled the AllowSorting property on the datagrid. What I have done for sorting is appended "order by table" with the corresponding table to my original query when the sortcommand event is fired. However, this executes a brand new query and returns a different set of data from the db. How can I sort the original dataset based upon one of the columns being selected?
Thanks.
|
|
|
| |
|
|
| |
| |
| Doug Rothaus \(MSFT\) |
Instead of binding to the DataSet, create a DataViewManager for the DataSet and bind to that. You can apply sort orders for each table in the DataSet (via their corresponding DataView) using the DataViewSettings collection of the DataViewManager. For example...
DataViewManager myDVM = new DataViewManager(myDS);
foreach (DataViewSetting myDVS in myDVM.DataViewSettings) myDVS.Sort = "Name";
myGrid.SetDataBinding(myDVM, "RootTable");
Note, for single table binding, you can simply use a DataView instead of a DataViewManager.
-- Doug Rothaus Click here to reveal e-mail address
------------------------------------------------------ This posting is provided "AS IS" with no warranties, and confers no rights.
"Scott Bansfield" <Click here to reveal e-mail address> wrote in message news:uAG9aUBhBHA.1644@tkmsftngp05... [Original message clipped]
|
|
|
| |
|
| |
| |
| Scott Bansfield |
| GOOD ANSWER |
Thanks this works great. I knew there had to be a way that I could do this and avoid doing it manually.
Scott
"Doug Rothaus (MSFT)" <Click here to reveal e-mail address> wrote in message news:#f0kcnMhBHA.1596@tkmsftngp02... > Instead of binding to the DataSet, create a DataViewManager for the DataSet [Original message clipped]
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|