C#
1 
2 
3 
4 
5 
6 
7 
NorthwindTableAdapters.ProductsTableAdapter 
productsAdapter = new 
NorthwindTableAdapters.ProductsTableAdapter(); 
Northwind.ProductsDataTable products; 
products = productsAdapter.GetProducts(); 
foreach (Northwind.ProductsRow productRow in products) 
Response.Write("Product: " + 
productRow.ProductName + "<br />"); 
ASP.NET
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
<%@ Page Language="C#" 
AutoEventWireup="true" CodeFile="AllProducts.aspx.cs" 
Inherits="AllProducts" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
<title>View All Products in a GridView</title> 
<link href="Styles.css" 
rel="stylesheet" 
type="text/css" 
/> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
<h1> 
All Products</h1> 
<p> 
<asp:GridView ID="GridView1" runat="server" 
CssClass="DataWebControlStyle"> 
<HeaderStyle CssClass="HeaderStyle" /> 
<AlternatingRowStyle CssClass="AlternatingRowStyle" /> 
</asp:GridView> 
 </p> 
</div> 
</form> 
</body> 
</html> 
C#
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
using System; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using NorthwindTableAdapters; 
public partial class 
AllProducts : System.Web.UI.Page 
{ 
protected void 
Page_Load(object sender, EventArgs e) 
{ 
ProductsTableAdapter productsAdapter = new 
ProductsTableAdapter(); 
GridView1.DataSource = productsAdapter.GetProducts(); 
GridView1.DataBind(); 
} 
} 
ASP.NET
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
<%@ Page Language="C#" 
AutoEventWireup="true" CodeFile="Beverages.aspx.cs" 
Inherits="Beverages" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
<title>Untitled Page</title> 
<link href="Styles.css" 
rel="stylesheet" 
type="text/css" 
/> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
<h1>Beverages</h1> 
<p> 
<asp:GridView ID="GridView1" runat="server" 
CssClass="DataWebControlStyle"> 
<HeaderStyle CssClass="HeaderStyle" /> 
<AlternatingRowStyle CssClass="AlternatingRowStyle" /> 
</asp:GridView> 
 </p> 
</div> 
</form> 
</body> 
</html> 
C#
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
using System; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using NorthwindTableAdapters; 
public partial class 
Beverages : System.Web.UI.Page 
{ 
protected void 
Page_Load(object sender, EventArgs e) 
{ 
ProductsTableAdapter productsAdapter = new 
ProductsTableAdapter(); 
GridView1.DataSource = 
productsAdapter.GetProductsByCategoryID(1); 
GridView1.DataBind(); 
} 
}