Why is DataViewManager not sorting?
First of all, a quick rundown of what the code does. I have two tables: companies and customers. There is one to many relationships between companies and customers (one company can have many customers).
In some processing logic, I have both tables loaded into the DataSet - each one is DataTables. I added a DataRelation to establish the relationship and it works when I use GetChildRows on the records from the companies table.
However, I need to sort the returned records. After some users run into errors, it looks like DataViewManager is the way to go and I've gone through a few basic examples. However, I am unable to sort the lines. Am I missing something or am I not using this, how should it be used? Sample code:
Dim ldvmManager As New DataViewManager(mdsData)
ldvmManager.DataViewSettings("Companies").Sort = "comName ASC"
ldvmManager.DataViewSettings("Clients").ApplyDefaultSort = False
ldvmManager.DataViewSettings("Clients").Sort = "entLastName ASC, entFirstName ASC"
For Each mdrCurrentCompany in ldvmManager.DataViewSettings("Companies").Table.Rows
Dim ldrClients() as DataRow = mdrCurrentCompany.GetChildRows("CompaniesClients")
Next
No matter what I do, the first customer returned has a last name starting with "B" and the second one starting with "A". From there the order is all messed up. If I use all of my data instead of the subset I used for testing, the first client returned has a last name that starts with "J". It looks like it is still using the default sorting used before I tried to use the DataViewManager.
Any ideas?
source to share