tailieunhanh - Beginning C# 2008 Databases From Novice to Professional phần 7

Visual Studio đi kèm với rất nhiều tính năng để giúp các nhà phát triển trong khi viết mã. Một trong những tính năng mà bạn chỉ có thể tăng gấp đôi vào các yếu tố giao diện mà bạn muốn thêm mã, và bạn sẽ được đưa đến mã kết hợp với các yếu tố giao diện theo quan điểm luật. | CHAPTER 13 USING DATASETS AND DATA ADAPTERS 283 create data view DataView dv new DataView dt country Germany country display data from data view foreach DataRowView drv in dv for int i 0 i i drv i t catch Exception e Error e finally close connection 3. Make DataViews the startup project and run it by pressing Ctrl F5. You should see the results in Figure 13-5. Figure 13-5. Using a data view 284 CHAPTER 13 USING DATASETS AND DATA ADAPTERS How It Works This program is basically the same as the other examples so we ll focus on its use of a data view. You create a new data view and initialize it by passing four parameters to its constructor. create data view DataView dv new DataView dt country Germany country The first parameter is a data table the second is a filter for the contents of the data table the third is the sort column and the fourth specifies the types of rows to include in the data view. is an enumeration of states that rows can have in a data view s underlying data table. Table 13-1 summarizes the states. Table 13-1. Data View Row States DataViewRowState Members Description Added A new row CurrentRows Current rows including unchanged new and modified ones Deleted A deleted row ModifiedCurrent The current version of a modified row ModifiedOriginal The original version of a modified row None None of the rows OriginalRows Original rows including unchanged and deleted rows Unchanged A row that hasn t been modified Every time a row is added modified or deleted its row state changes to the appropriate one in Table 13-1. This is useful if you re interested in retrieving sorting or filtering specific rows based on their state for example all new rows in the data table or all rows that have been modified . You then loop through the rows in the data view. CHAPTER 13 USING DATASETS AND DATA .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.