ASP.NET 4 Unleased - p 64

Sử dụng Control FormView Bạn có thể sử dụng kiểm soát FormView để làm bất cứ điều gì mà bạn có thể làm với các điều khiển DetailsView. Cũng như bạn có thể với sự kiểm soát DetailsView, bạn có thể sử dụng kiểm soát FormView để hiển thị, trang, chỉnh sửa, chèn, và xóa các bản ghi cơ sở dữ liệu. | 604 CHAPTER 12 Using the DetailsView and FormView Controls GridLines None HeaderText Movies CssClass movies HeaderStyle-CssClass header FieldHeaderStyle-CssClass fieldHeader AlternatingRowStyle-CssClass alternating CommandRowStyle-CssClass command PagerStyle-CssClass pager Runat server asp SqlDataSource id srcMovies ConnectionString ConnectionStrings Movies SelectCommand SELECT Title Director InTheaters FROM Movies InsertCommand INSERT Movies Title Director InTheaters VALUES @Title @Director Runat server div form body html Using the FormView Control You can use the FormView control to do anything that you can do with the DetailsView control. Just as you can with the DetailsView control you can use the FormView control to display page edit insert and delete database records. However unlike the DetailsView control the FormView control is entirely template-driven. I use the FormView control much more than the DetailsView control. The FormView control provides you with more control over the layout of a form. Furthermore adding validation controls to FormView is easier than adding validation controls to a DetailsView control. WEB STANDARDS NOTE By default the FormView control renders an HTML table. It creates an HTML table that contains a single cell. In ASPNET 4 you can disable this by setting the RenderOuterTable property to False. This enables you to style the output using CSS styles. From the Library of Wow eBook Using the FormView Control 605 Displaying Data with the FormView Control You can display a database record with the FormView control by using an ItemTemplate. For example the page in Listing displays a record from the Movies database table see Figure . FIGURE Displaying a database record with the FormView control. LISTING 12 @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD html xmlns http 1999 xhtml head id Head1 runat server style type text css html

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.