ASP. NET DetailsView displays the details of the selected product

Source: Internet
Author: User

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

  1. ASP. NET 2.0 data Tutorial: Add and configure the ObjectDataSource Control
  2. ASP. NET 2.0 data Tutorial: add the Default. aspx page to each part
  3. ASP. NET 2.0 data Tutorial: Add breadcrumb navigation
  4. ASP. NET 2.0 data Tutorial: SiteMapDataSource Control
  5. ASP. NET 2.0 data Tutorial: Add a site map

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.