thread732-333932
I realize that this is in reference to an old thread, but since it comes up on a search, and since someone else may have the same question to be answered, here it is:
You can not define a sort with multiple fields on a DataView and execute the FindRows method using a key that only has some of the fields in the sort key. Going by the provided example, the data must first be sorted in the underlying DataTable, thus:
Then, the sort should be on the one field that is required for the FindRows operation, thus:
The VALUE field in this example will still retain its sorting order from the DataTable.
iamanson said:Hi,
If my DataView contains data
ID VALUE
APPLE 1
APPLE 3
APPLE 2
ORANGE 1
ORANGE 4
ORANGE 2
ORANGE 3
Can I use .FindRows to get DataRowView data ID=ORANGE and sorted by VALUE?
I tried
DataView.Sort="ID, VALUE";
DataRowView [] = DataView.FindRows("ORANGE");
but it's not a valid syntax.
I realize that this is in reference to an old thread, but since it comes up on a search, and since someone else may have the same question to be answered, here it is:
You can not define a sort with multiple fields on a DataView and execute the FindRows method using a key that only has some of the fields in the sort key. Going by the provided example, the data must first be sorted in the underlying DataTable, thus:
Code:
ID VALUE
APPLE 1
APPLE 2
APPLE 3
ORANGE 1
ORANGE 2
ORANGE 3
ORANGE 4
Then, the sort should be on the one field that is required for the FindRows operation, thus:
Code:
myDataView.Sort = "ID";
DataRowView[] myDataRowView = myDataView.FindRows("ORANGE");
The VALUE field in this example will still retain its sorting order from the DataTable.