Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Hãy có một cái nhìn chi tiết hơn ở một dịch vụ Web. Chúng tôi cũng sẽ bắt đầu khám phá khả năng sử dụng cho các dịch vụ Web. Bạn có thể định nghĩa một dịch vụ Web bằng cách chỉ đơn giản là viết một vài dòng mã và đặt chúng vào trong một tập tin có phần mở rộng asmx | Exercise Solutions string connectionstring ConfigurationSettings.AppSettings ConnectionString System.Data.IDbConnection dbConnection new System.Data.OleDb.OleDbConnection connectionString string queryString SELECT Players . PlayerName Positions . PositionName Teams . TeamName FROM Players Positions PlayerTeam Teams WHERE PlayerTeam . PlayerID Players . PlayerID AND PlayerTeam . Position Positions . PositionID AND PlayerTeam . TeamID Teams . TeamID AND Players . PlayerID @PlayerID System.Data.IDbCommand dbCommand new System.Data.OleDb.OleDbCommand dbCommand.CommandText queryString dbCommand.Connection dbConnection System.Data.IDataParameter dbParam_teamID new System.Data.OleDb.OleDbParameter dbParam_teamID.ParameterName @PlayerID dbParam_teamID.Value playerID dbParam_teamID.DbType System.Data.DbType.Int32 dbCommand.Parameters.Add dbParam_teamID dbConnection.Open System.Data.IDataReader dataReader dbCommand.ExecuteReader System.Data.CommandBehavior.CloseConnection return dataReader The GetTeamsByPlayer method is a very simple alteration of GetPlayersByTeam from the Teams page. The really tricky part on this page is that we need to obtain the ID of the player that the user selects. In the Team page that was easy - we packaged up each team s ID as the CommandArgument for the LinkButton in the teams DataList. But a DataGrid won t let us do that so we need to find another solution. Remember the fields we set up on the players DataGrid At the left hand side there was an invisible column that contained the player ID. This is how we get it TableCell cell TableCell e.Item.Controls 0 int SelectedPlayerID int.Parse cell.Text Chapter 11 This chapter deals with tracking users across pages and looks at the ASP.NET objects that are used to enable this feature. Exercise 1 Add some text Current Topic and a Label control to the Chat.aspx page above the main chat box which contains the text of the current topic stored in the Application object . Add some default topic 693 Appendix A .