Wrox’s ASP.NET 2.0 Visual Web Develope 2005 Express Edition Starter Kit phần 7

Trong hai chương trước, chúng tôi đã xem xét nhiều cách khác nhau của dữ liệu hiển thị, sử dụng kiểm soát nguồn dữ liệu và mạng lưới cung cấp với . Trong khi dữ liệu hiển thị là một yêu cầu cốt lõi của nhiều trang web, có lần khi bạn cũng cần phải cho phép chỉnh sửa, | 6 Managing and Editing Data In the previous two chapters we have looked at various ways of displaying data using the data source controls and grids supplied with . While displaying data is a core requirement of many Web sites there are times when you also need to allow editing and you can use the same controls as for displaying data. In the PPQ application users have no need to update data but the site administrators might to update the menu and prices. In this chapter we are going to see how the administrator of a site can perform edits on the data. In particular we ll be looking at How to modify the SqlDataSource control to allow data editing How to configure the Gridview to allow data editing. Both of these topics extend techniques you ve already used so you will find this a natural progression into your exploration of data controls. Data Source Controls In Chapter 4 you saw how the SqlDataControl was used to fetch data from a database by specifying a SQL command in the SelectCommand property. When the page is loaded the SqlDataSource object opens a connection to the database and runs this command to fetch the data. The SqlDataControl also has properties that allow you to define the command to be run to modify data which are the Insertcommand UpdateCommand and DeleteCommand properties. You ve already seen these in action even if you didn t realize it when you used the test menu pages in Chapter 4 the grid had editing capabilities . The properties of the SqlDataSource control allow you to specify different SQL commands for different types of operation. So we have the following properties Chapter 6 SelectCommand which you use to fetch data from the database Insertcommand which you use to insert data into the database UpdateCommand which you use to update data in the database DeleteCommand which you use to delete data from the database When you drag a table from the Database Explorer and drop it onto a page these properties are automatically set for you. But

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.