tailieunhanh - Editing Data

Chỉnh sửa dữ liệu Bạn đã thấy làm thế nào để sử dụng điều khiển GridView để lấy và duyệt dữ liệu. Dưới đây tập hợp các bài tập tập trung vào xoá bỏ và sửa đổi dữ liệu sử dụng điều khiển GridView. | Editing Data You have seen how to use a GridView control to fetch and browse data. The following set of exercises concentrate on deleting and modifying data using a GridView control. Deleting Rows from a GridView Control The GridView control allows you to add buttons to the grid to indicate that a command should be performed. You can add your own custom buttons and commands but Visual Studio 2005 supplies some predefined buttons for deleting and editing data. In the following exercise you will add a Delete button to the GridView control. Create the Delete button 1. Ensure that is displayed in the Design View window. Click the Smart Tag icon to display the GridView Tasks menu. 2. On the GridView Tasks menu check the Enable Deleting box. A hyperlink labeled Delete is added to the start of each row in the GridView control. 3. On the GridView Tasks menu click Edit Columns. The Fields dialog box is displayed. You can use this dialog box to set the properties of the fields columns displayed in the GridView control. 4. In the Selected fields list select the Delete field. In the CommandField properties list change the ButtonType property to Button. Click OK. The Delete link in the GridView control changes to a button. 5. Run the application. Log in and then go to page 3 of the data. Delete the customer with the ID of FISSA. This should be successful. Try to delete customer FAMIA. This will fail with an error because this customer has outstanding orders the referential integrity rules of the Northwind Traders database forbid you from deleting a customer that has outstanding orders. TIP The exception that is displayed is not very user-friendly although a developer will find it very useful . If a Web form generates an exception you can arrange for a more friendly message to be displayed by redirecting the user to another page using the ErrorPage attribute to the @Page directive in the form s source definition @ Page . ErrorPage- You can .

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.