Nick_Net2004 Posted May 17, 2004 Posted May 17, 2004 I want to know if there is an option to sort the elements, let say all the row from one column in a datatable?? Quote
tbekasiewicz Posted May 17, 2004 Posted May 17, 2004 Sorting DataTable If you want to sort a DataTable you must first build a DataView. There is some parameters in the DataView constructor. Public Sub New(DataTable, String, String, DataViewRowState) (This is a hyperlink to the topic in .NET Framework SDK) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclassctortopic3.asp (This is a hyperlink to the topic in MSDN Library) One of them is a DataTable which you want to sort, the others are the parameters of the RowFilter, type of Sort and a DataViewRowSate. You must write such a code: Dim dv As New DataView(ds.Tables("Suppliers"), _ "Country = 'UK'", _ "CompanyName", _ DataViewRowState.CurrentRows) dv.AllowEdit = True dv.AllowNew = True dv.AllowDelete = True With regards Tomasz Bekasiewicz Quote
mocella Posted May 17, 2004 Posted May 17, 2004 DataTable.Select() will also allow you to specify a sort-order/selection-criteria, but it loads the results into a DataRow array. Quote
JABE Posted May 18, 2004 Posted May 18, 2004 If you want to sort a DataTable you must first build a DataView. You can also sort w/o explicitly building a new dataview by accessing theDataTable.DefaultView. Quote
legendgod Posted May 18, 2004 Posted May 18, 2004 Is it when a dataview is changed/updated, the datatable (Let's say: ds.Tables("Suppliers") ) will be updated at the same time? Quote http://blog.legendgod.com
JABE Posted May 18, 2004 Posted May 18, 2004 The underlying datatable will be updated for as long as the dataview is configured to be updateable (via AllowNew, AllowEdit and/or AllowDelete properties) and the changes made to the dataview have been committed. Quote
Nick_Net2004 Posted May 18, 2004 Author Posted May 18, 2004 OK I wasn't clear enough in my explication. I stored a PRI(Number), first name, last name in a datatable in separate column, so that every row as the information for a client. Now I got 2 list, in the first one in want to show the PRI number so that they in increasing order, and in the second one I got the first name concatenate with the last name and I want to order that list alphabetically. The thing is if I set property sorted to true in both list when I will select one PRI it won't select the rigth name in the second list. So I wont to sort both list and when I select a value in an one it select the respective value in the second one... Quote
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.