hog Posted December 24, 2003 Posted December 24, 2003 When I use this code to sort a dataview I can't seem to get hold of the correct row within the dataview? My understanding of this code snippet is sort the dataview by the score column default to ascending. Display the fist rows second column. This should display the lowest score, but it does not? Any ideas? :( dvDataView.Sort = "Score" MessageBox.Show(dvDataView.Table.Rows(0).Item(1)) Quote My website
*Experts* Nerseus Posted December 30, 2003 *Experts* Posted December 30, 2003 When you use the Table property on a DataView, it goes back to the original DataTable. That table does have a Rows property (which you use), but it knows nothing of the DataView. If you use the Rows property of the DataView, you'll get the sorted rows. I assume dvDataView is a new DataView below: Dim dvDataView As DataView = New DataView(...) dvDataView.Sort = "Score" MessageBox.Show(dvDataView.Rows(0).Item(1)) If you want the lowest score ONLY, try using the DataTable's Compute method, something like: dt.Tables(0).Compute("MIN(Score)") -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.