• HyperLink Column Cột dạng Liên Kết. • Template Column Cột tự thiết kế[r]
Trang 1CH ƯƠ NG VII:
Lý thuyết : 3 tiết
Thực hành 12 tiết
Trang 2 DataGrid =Table(đ ng độ ượ ạc t o trên server)
Repeater
DataList
GridView
Trang 3Các properties c a Data Controls ủ
Properties DataList DataGrid Column Layout(sắp xếp theo cột) X
Paging(Hiển thị số trang) X
Select/Edit/Delete X X
Style Properties(Kiểu c ách) X X
Table Layout(Hiển thị kiểu Bảng) X
Template(Sử dụng khuôn mẫu) X X
Trang 4 Ý nghĩa: Cung c p m t d ng b ng tính d li u t ấ ộ ạ ả ữ ệ ừ
data source
G m t p các c t, m t header, m t footer ồ ậ ộ ộ ộ
Các c t có th t đ ng t o ho c t ộ ể ự ộ ạ ặ ườ ng minh
Thu c tính:ộ
03CDTH632
……
03CDTH892
Student ID
DataField
……
DataField
HeadText
<asp:BoundColumn DataField =“IDs” HeadText =“Student ID” />
Trang 5Properties Descriptions
AutoGenerateColumns Tạo column tự động()
Column (Design & Coding)
• Bound Column Cột dữ liệu
• Button Column Cột dạng Button
• HyperLink Column Cột dạng Liên Kết
• Template Column Cột tự thiết kế
Header Style(Show Footer: true) Định dạng Header
Footer Style(Show Header: true) Định dạng Footer
Trang 6Ví d : ụ
T o đi u khi n (Design) ạ ề ể
Ràng bu c vào DataReader/Dataset: (Coding) ộ
dgAuthors.DataSource = dr;
dgAuthors.DataBind();
dgAuthors.DataSource = dr;
dgAuthors.DataBind();
<asp:DataGrid id="dgAuthors" runat="server" />
dgAuthors.DataSource = ds.Table[0]; dgAuthors.DataBind();
dgAuthors.DataSource = ds.Table[0]; dgAuthors.DataBind();
Trang 7<form id="form1" runat="server">
<div>
<asp:DataGrid ID="DataGrid1" runat="server"
Style="zindex: 100; left: 55px; position: absolute;top: 15px"> </asp:DataGrid>
</div>
</form>
Trang 8DataGrid Editing
S d ng EditCommandColumn ử ụ
Thu c tính ộ EditItemIndex (1 >không có
dòng nào được hi u ch nh)ệ ỉ
EditCommandColumn hi n th 3 liên k t ể ị ế
tương ng 3 s ki n: OnEditCommand, ứ ự ệ OnUpdateCommand, OnCancelCommand
Trang 9 DataGridCommandEventArgs ch a thông ứ
tin c a dòng s đủ ẽ ược hi u ch nhệ ỉ
Thu c tính DataKeyField ộ thi t l p khóa ế ậ
chính
S ki n UpdateCommand ự ệ , truy xu t t p ấ ậ
các DataKeys đ thao tác trên khóa chínhể
Trang 10GridView các s ki n ự ệ
OnEditCommand =“FunctionEdit"
OnCancelCommand =“FunctionCancel“ OnPageIndexChanged =“FunctionPage" OnDeleteCommand =“FunctionDelete" OnItemCommand =“FunctionCommand"