tailieunhanh - Filtering for Null Values

[ Team LiB ] Recipe Filtering for Null Values Problem You want to filter a DataView for rows that have null values. Solutions Use the IS NULL clause with the RowFilters property of the DataView. The sample code contains two event handlers | Team LiB Recipe Filtering for Null Values Problem You want to filter a DataView for rows that have null values. Solutions Use the IS NULL clause with the RowFilters property of the DataView. The sample code contains two event handlers Sets up the sample by creating a DataTable containing the Orders table from the Northwind sample database. The default view of the table is bound to the data grid on the form. Filter Toggles on and off the filter on the data view that selects only rows with a null ShipRegion. The C code is shown in Example 3-12. Example 3-12. File Namespaces variables and constants using System using using using Table name constants private const String ORDERS_TABLE Orders Field name constants private const String SHIPREGION_FIELD ShipRegion . . . private void FilterNullValuesForm_Load object sender e Create and fill the Orders table. DataTable dt new DataTable ORDERS_TABLE SqlDataAdapter da new SqlDataAdapter SELECT FROM Orders S ql_ConnectString dt Bind the default view to the grid. private void filterButton_Click object sender e String filter SHIPREGION_FIELD IS NULL DataView dv DataView Apply Filter Apply the filter. filter Orders table filtered for null ShipRegion field. Remove Filter else Remove the filter. Orders table no filter. Apply Filter Discussion Every DataTable has a default DataView associated with it that can filter a table for records meeting specific criteria. In the solution the RowFilter property of the DefaultView is filtered for rows containing a null ShipRegion field. The result of applying the filter is immediately reflected in any controls bound to the DataView object .

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.