1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Using the Default Sort Algorithm docx

1 318 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Using the Default Sort Algorithm
Định dạng
Số trang 1
Dung lượng 8,3 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

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

Trang 1

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, you set the PrimaryKey property of your DataTable and then set the

ApplyDefaultSort property of your DataView to true

The Sort property of your DataView is then automatically set to the primary key of your DataTable This causes the DataRowView objects in your DataView to be sorted in ascending order based on the primary key column values

Let's take a look at an example The following code sets the PrimaryKey property of the customersDT 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 the

DataRowView objects to be sorted by the ascending CustomerID values

Note You'll find the code examples in this section in the UsingDefaultSort.cs program

The listing is omitted from this book for brevity

Ngày đăng: 24/12/2013, 01:17

w