Danh mục

Using the Default Sort Algorithm

Số trang: 1      Loại file: pdf      Dung lượng: 8.30 KB      Lượt xem: 2      Lượt tải: 0    
Thư viện của tui

Xem trước 1 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Using the Default Sort Algorithm If you want to sort the DataRowView objects in your DataView based on the primary key of your DataTable, you can use a shortcut. Instead of setting the Sort property of your DataView
Nội dung trích xuất từ tài liệu:
Using the Default Sort AlgorithmUsing the Default Sort AlgorithmIf you want to sort the DataRowView objects in your DataView based on the primary keyof your DataTable, you can use a shortcut. Instead of setting the Sort property of yourDataView, you set the PrimaryKey property of your DataTable and then set theApplyDefaultSort property of your DataView to true.The Sort property of your DataView is then automatically set to the primary key of yourDataTable. This causes the DataRowView objects in your DataView to be sorted inascending order based on the primary key column values.Lets take a look at an example. The following code sets the PrimaryKey property of thecustomersDT DataTable to the CustomerID DataColumn:customersDT.PrimaryKey = new DataColumn[] { customersDT.Columns[CustomerID] };The next example sets the ApplyDefaultSort property of customersDV to true:customersDV.ApplyDefaultSort = true;The Sort property of customersDV is then set to CustomerID, which causes theDataRowView objects to be sorted by the ascending CustomerID values.Note Youll find the code examples in this section in the UsingDefaultSort.cs program. The listing is omitted from this book for brevity.

Tài liệu được xem nhiều: