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:
- < asp:GridView ID="HighlightCheapProducts" runat="server" AutoGenerateColumns="False"
-
- DataKeyNames="ProductID" DataSourceID="ObjectDataSource1" EnableViewState="False">
-
- < Columns>
-
- < asp:BoundField DataField="ProductName" HeaderText="Product" SortExpression="ProductName" />
-
- < asp:BoundField DataField="CategoryName" HeaderText="Category" ReadOnly="True" SortExpression="CategoryName" />
-
- < asp:BoundField DataField="UnitPrice" DataFormatString="{0:c}" HeaderText="Price"
-
- HtmlEncode="False" SortExpression="UnitPrice" />
-
- < /Columns>
-
- < /asp:GridView>
-
Display the browser view results
ASP. NET GridView: The GridView displays the product name, category, and price.
- ASP. NET 2.0 data Tutorial: Use of the SelectMethod attribute
- ASP. NET 2.0 data Tutorial: Add a method to the business logic layer
- ASP. NET 2.0 data Tutorial: Add a method for TableAdapter
- ASP. NET 2.0 data Tutorial: using a hard-coded parameter value
- ASP. NET 2.0 data Tutorial: bind to ObjectDataSource