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.NetdtgKhach_hang.EditItemIndex = e.Item.ItemIndexLien_ket_du_lieu()End SubPrivate Sub dtgKhach_hang_UpdateCommand(…, e …) …'Khai báo và khởi tạo biến kết nối: cnKet_noi'Lấy dữ liệu mà người dùng vừa cập nhậtDim lHo_kh As TextBox = e.Item.Cells(0).Controls(0)Dim lTen_kh As TextBox = e.Item.Cells(1).Controls(0)Dim lPhai As CheckBox = e.Item.FindControl("chkPhai")Dim lMkh As Integer = dtgKhach_hang.DataKeys(e.Item.ItemIndex)'Tạo đối tượng Command để cập nhật dữ liệuDim cmdLenh As New OleDbCommandcmdLenh.Connection = cnKet_noicmdLenh.CommandText = "Update KHACH_HANG " & _"Set Ho_khach_hang=?, Ten_khach_hang=?, " & _"Gioi_tinh=? Where MKH=?"'Truyền tham số cho đối tượng CommandcmdLenh.CommandType = CommandType.TextcmdLenh.Parameters.Add("Ho_kh", lHo_kh.Text)cmdLenh.Parameters.Add("Ten_kh", lTen_kh.Text)cmdLenh.Parameters.Add("Phai", lPhai.Checked)cmdLenh.Parameters.Add("Mkh", lMkh)'Thi hành CommandcnKet_noi.Open()cmdLenh.ExecuteNonQuery()cnKet_noi.Close()'Tắt chế độ cập nhật dữ liệudtgKhach_hang.EditItemIndex = -1'Hiển thị dữ liệu mới cập nhật lên lướiLien_ket_du_lieu()End SubPrivate Sub dtgKhach_hang_CancelCommand(…, e …) …dtgKhach_hang.EditItemIndex = -1Lien_ket_du_lieu()End SubHiệu chỉnh độ rộng của các Textbox khi dòng ở trạng thái sửaBạn có thể bổ sung đoạn lệnh sau (trong sự kiện ItemDataBound) để hiệu chỉnh độ rộng cácTextbox của dòng ở trạng thái sửa.www.Beenvn.comBiên sọan: Dương Thành Phết Trang 125

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

Saved successfully!

Ooh no, something went wrong!