TAILIEUCHUNG - Adding, Modifying, and Removing DataRowView Objects from a DataView

Adding, Modifying, and Removing DataRowView Objects from a DataView It's important to understand that DataRowView objects in a DataView provide access to the underlying DataRow objects in a DataTable. | Adding Modifying and Removing DataRowView Objects from a DataView It s important to understand that DataRowView objects in a DataView provide access to the underlying DataRow objects in a DataTable. Therefore when you examine and edit the contents of a DataRowView you re actually working with the underlying DataRow. Similarly when you remove a DataRowView you are removing the underlying DataRow. Adding a DataRowView to a DataView To add a new DataRowView to a DataView you call the AddNew method of your DataView. The AddNew method returns a DataRowView object that you use to set the column values for the new following example calls the AddNew method of the customersDV DataView DataRowView customerDRV customerDRV CustomerID J7COM customerDRV CompanyName J7 Company customerDRV Country UK Notice the use of the EndEdit method of the customerDRV DataRowView to end the editing. The EndEdit method creates a new DataRow in the underlying DataTable. The DataColumn objects in the new DataRow will contain the column values specified in the previous code. Note You can undo the addition by calling the CancelEdit method of a DataRowView. You can get the underlying DataRow added to the DataTable using the Row property of a DataRowView. For example DataRow customerDR Modifying an Existing DataRowView To begin modifying an existing DataRowView in a DataView you call the BeginEdit method of the DataRowView in your DataView. The following example calls the BeginEdit method for the first DataRowView in customersDV customersDV 0 .BeginEdit Note Remember that DataRowView objects in a DataView start at index 0 and therefore customersDV 0 is the first DataRowView in customersDV. You can then modify a DataColumn in the underlying DataRow through the DataRowView. The following example sets the CompanyName DataColumn to Widgets Inc. customersDV 0 CompanyName Widgets Inc. Once you ve finished making your modifications you call the

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