12.07.2015 Views

MỤC LỤC - lib

MỤC LỤC - lib

MỤC LỤC - lib

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Bài Giảng Môn Lập Trình Website ASP.NetII.2. Cập nhật dữ liệu với DataListNgoài việc hiển thị dữ liệu, DataList cũng hỗ trợ các thao tác cập nhật dữ liệu. Để thực hiệnchứcnăng cập nhật dữ liệu với DataList, chúng ta cần phải thiết kế thêm vùng EditIemTemplate choDataList. (xem hình)II.2.1. Các bước xử lýa. Thiết kếThiết kế cả 2 vùng ItemTemplate và EditItemTemplate. Thực hiện các thao tác liên kết dữ liệuchocác điều khiển trong vùng EditItemTemplate thông qua cửa sổ thuộc tính tương tự như trongItemTemplate.Chú ý: Chúng ta hoàn toàn có thể thực hiện việc liên kết dữ liệu trong sự kiện ItemDataBound.Chọn chức năng DataBindings cho ô Đơn giáLiên kết dữ liệu với cột Don_giaYêu cầu thiết kếTên điều khiển Thiết lập thuộc tínhHieu_chinh: ImageButton CommandName: EditGhi_nhan: ImageButton CommandName: UpdateCommandArgument:DataBinder.Eval(Container, "DataItem.Ms") Lưu lại mã số của sách đang hiệu chỉnh.Bo_qua: ImageButton CommandName: CancelTài liệu hướng dẫn giảng dạyHọc phần 3 - Lập trình ứng dụng web với ASP.NET Trang 85/174b. Xử lý lệnh để cập nhật dữ liệuXử lý các sự kiện EditCommand, CancelCommand, UpdateCommand để thực hiện/bỏ qua việcthayđổi dữ liệu.Private Sub Page_Load(…, e …) Handles MyBase.Load'Put user code to initialize the page hereIf Not IsPostBack ThenLien_ket_du_lieu()End IfEnd SubPrivate Sub dtlHang_hoa_EditCommand(…, e …) …dtlHang_hoa.EditItemIndex = e.Item.ItemIndexLien_ket_du_lieu()End SubPrivate Sub dtlHang_hoa_CancelCommand(…, e …) …www.Beenvn.comBiên sọan: Dương Thành Phết Trang 129

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!