Display product information in ASP. NET GridView

Source: Internet
Author: User

In ASP. NET GridView shows product information. First, add a GridView To the bottom of FormView and set the ID to HighlightCheapProducts. we have already set an ObjectDataSource to retrieve product data. Now we bind the GridView to the ObjectDataSource. then, edit the GridView binding column to include the product name. categorie and price attributes. The ASP. NET GridView code is as follows:

 
 
  1. < asp:GridView ID="HighlightCheapProducts" runat="server" AutoGenerateColumns="False" 
  2.  
  3.     DataKeyNames="ProductID" DataSourceID="ObjectDataSource1" EnableViewState="False">  
  4.  
  5.     < Columns>  
  6.  
  7.         < asp:BoundField DataField="ProductName" HeaderText="Product" SortExpression="ProductName" />  
  8.  
  9.         < asp:BoundField DataField="CategoryName" HeaderText="Category" ReadOnly="True" SortExpression="CategoryName" />  
  10.  
  11.         < asp:BoundField DataField="UnitPrice" DataFormatString="{0:c}" HeaderText="Price" 
  12.  
  13.             HtmlEncode="False" SortExpression="UnitPrice" />  
  14.  
  15.     < /Columns>  
  16.  
  17. < /asp:GridView>  
  18.  

Display the browser view results

 

ASP. NET GridView: The GridView displays the product name, category, and price.

  1. ASP. NET 2.0 data Tutorial: Use of the SelectMethod attribute
  2. ASP. NET 2.0 data Tutorial: Add a method to the business logic layer
  3. ASP. NET 2.0 data Tutorial: Add a method for TableAdapter
  4. ASP. NET 2.0 data Tutorial: using a hard-coded parameter value
  5. ASP. NET 2.0 data Tutorial: bind to ObjectDataSource

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.