Đang chuẩn bị liên kết để tải về tài liệu:
vb.net book phần 7
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Thiết lập thuộc tính Neo của DataGrid ALL và xây dựng các hình thức hoàn thành solution.The sẽ giống như hình 9,7 và 9,8. Sau khi bạn nhấn F5, nhấn nút, và mở rộng nút mặc định. Hình 9,7 mẫu hoàn thành | 442 Chapter 9 Using ADO.NET This line binds the TypedDataSet to the DataGrid DataGridl.DataSource tdsOrdersl 6. Set the Anchor property of the DataGrid to ALL and build the solu-tion.The finished form should look like Figures 9.7 and 9.8. After you press F5 click the button and expand the default node. Figure 9.7 Finished Form Figure 9.8 Orders Table www.syngress.com Using ADO.NET Chapter 9 443 Click the plus sign to get a list of tables in our DataSet. Select the Orders table from the drop-down to get the view shown in Figure 9.8. In our example we start out with a list of orders and we can expand them by clicking the plus sign at the record selector in the far left of the grid.This provides us with a list of relations. In our example we only have the one so select it and the grid will change to show the detail records for that order.When you consider that we started with a project that consisted of dragging and dropping some objects from the Server Explorer and the toolbox entering half a dozen lines of code this is pretty powerful stuff The WebForm DataGrid object in ASP.NET is quite a bit different as far getting one to operate. A few lines of code are all it takes to put one of these to work with some basic functionality.The following example creates a basic HTML table of our data with just a few lines of code.This is the line of code that will actually place the control on the form for us. Place it where you would like the grid to show up on the page see CD file Chapter 09 Chapter9 Beta2 Samples wwwroot Chapter9 DataGridSample.aspx asp DataGrid id DGOrders runat server All that is left to do is to populate the grid with a data source Private sConn As String MyConnectionstring Private dsShippers As DataSet Private Sub BindData Dim strSQLQuery As String Dim objConn As SqlClient.SqlConnection Dim objAdapter As SqlClient.SqlDataAdapter strSQLQuery SELECT FROM Shippers Create a connection to the SQL Server objConn New SqlClient.SqlConnection sConn Create a .