Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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.

Posted
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.
Posted

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...