After the ProductsGrid GridView is completed, a DetailsView is added, which displays the details of the selected product. add a DetailsView control at the top of the GridView and create a new data source named ProductDetailsDataSource. because we want this DetailsView to display the details of the selected product, configure ProductDetailsDataSource to use the GetProductByProductID (productID) method of the ProductsBLL class.
ASP. NET DetailsView: Call the GetProductByProductID (productID) method of the ProductsBLL class.
Let productID obtain the parameter value from the SelectedValue attribute of the GridView control. as we have discussed earlier, the SelectedValue attribute of the GridView returns the first data key value of the selected row. therefore, you must set the DataKeyNames attribute of the GridView to ProductID, so that the ProductID of the selected row can be returned through the SelectedValue attribute.
ASP. NET DetailsView: associates the productID parameter with the SelectedValue attribute of the GridView.
After configuring productDetailsDataSource ObjectDataSource and binding it to DetailsView, this tutorial is complete! No row is selected during the first access, so the SelectedValue attribute of the GridView returns null. because there is no product whose ProductID value is Null, The GetProductByProductID (productID) method does not return any records, and the DetailsView cannot be displayed (11 ). clicking the select button of the GridView will cause a sending back and update the DetailsView. the SelectedValue attribute of the GridView returns the ProductID of the selected row, and the GetProductByProductID (productID) method returns the ProductsDataTable information of the specific product. The DetailsView displays the details (12 ).
ASP. NET DetailsView: only the GridView is displayed during the first access
ASP. NET DetailsView: displays the product details after selecting a row
- ASP. NET 2.0 data Tutorial: Add and configure the ObjectDataSource Control
- ASP. NET 2.0 data Tutorial: add the Default. aspx page to each part
- ASP. NET 2.0 data Tutorial: Add breadcrumb navigation
- ASP. NET 2.0 data Tutorial: SiteMapDataSource Control
- ASP. NET 2.0 data Tutorial: Add a site map