Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Các nội dung có thể thay đổi tùy thuộc vào cấu hình cơ sở dữ liệu của bạn. Các dữ liệu thực tế bắt buộc xảy ra thông qua các tính năng dữ liệu cho phép của điều khiển GridView. | 366 Microsoft ADO.NET 4 Step by Step -- This is just the connection string portion of the Web.config file. -- connectionStrings add name StepSampleConnectionString1 connectionString Data Source local SQLExpress Initial Catalog StepSample Integrated Security True providerName System.Data.SqlClient connectionStrings The content can vary depending on your database configuration. The actual data binding occurs through the data-enabled features of the GridView control. asp GridView ID GridView1 runat server AutoGenerateColumns False DataKeyNames CourseID DataSourceID SqlDataSource1 EmptyDataText There are no data records to display. Columns asp BoundField DataField CourseID HeaderText CourseID ReadOnly True SortExpression CourseID asp BoundField DataField CourseName HeaderText CourseName SortExpression CourseName asp CheckBoxField DataField OfferedFall HeaderText OfferedFall SortExpression OfferedFall asp CheckBoxField DataField OfferedSpring HeaderText OfferedSpring SortExpression OfferedSpring asp BoundField DataField CreditHours HeaderText CreditHours SortExpression CreditHours asp BoundField DataField Prerequisite HeaderText Prerequisite SortExpression Prerequisite Columns asp GridView The control s DataSourceID references the SqlDataSource instance that will supply the bound data. Within the control s Columns tag a collection of asp BoundField instances and their DataField attributes identify the path needed to locate the display data within the source. The control also includes an EmptyDataText attribute that adjusts the grid s content in the running application if the source lacks data records. It s a surprisingly small amount of code for the functionality it brings to the web page and it works without adding a single line of custom C or Visual Basic code. Chapter 21 Binding Data with ADO.NET 367 Summary This chapter introduced some of the data binding options available in different flavors of Visual Studio projects Windows Forms Windows Presentation Foundation .