asp.net中数据链路层的创建(7)
来源:互联网 发布:编程笔记本推荐2017 编辑:程序博客网 时间:2024/06/05 00:14
花点时间用同样的手法添加一个GetProductByProductID(productID)
方法。
这些参数化的查询可以在DataSet设计器里直接测试。在TableAdapter中的方法上按右鼠标,然后选择“预 览数据(Preview Data)”。接着,输入对应参数的值,然后按“预览(Preview)”。
图19: 属于饮料(Beverages)类的那些产品列单
通过我们的DAL中的GetProductsByCategoryID(categoryID)
方法,我们就能设计一 个ASP.NET网页来显示属于指定分类的那些产品。下面这个例子显示了属于Beverages(饮 料)类(CategoryID
=1)的所有产品。
Beverages.aspx
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 Pagetitle>
<link href="Styles.css"
rel="stylesheet"
type="text/css"
/>
head>
<body>
<form id="form1" runat="server">
<div>
<h1>Beveragesh1>
<p>
<asp:GridView ID="GridView1" runat="server"
CssClass="DataWebControlStyle">
<HeaderStyle CssClass="HeaderStyle" />
<AlternatingRowStyle CssClass="AlternatingRowStyle" />
asp:GridView>
p>
div>
form>
body>
html>
Beverages.aspx.cs
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();
}
}
图 20: 属于Beverages(饮料)类的所有产品显示
- asp.net中数据链路层的创建(7)
- asp.net中数据链路层的创建(5)
- asp.net中数据链路层的创建(1)
- asp.net中数据链路层的创建(2)
- asp.net中数据链路层的创建(3)
- asp.net中数据链路层的创建(4)
- asp.net中数据链路层的创建(6)
- asp.net中数据链路层的创建(8)
- asp.net中数据链路层的创建(9)
- asp.net中数据链路层的创建(10)
- asp.net中数据链路层的创建(11)
- asp.net中数据链路层的创建(12)
- asp.net中数据链路层的创建(13)
- 数据链路层的协议
- 数据链路层的主要功能
- 数据链路层的数据传输
- 数据链路层的功能
- 数据链路层的功能
- Mastering Joomla! 1.5 Extension and Framework Development-第九章翻译-系统消息队列(2)
- asp.net中数据链路层的创建(6)
- 掌握 Linux 调试技术(1)
- 掌握 Linux 调试技术(2)
- 出现could not find java 2 Runtime Environment错误的处理
- asp.net中数据链路层的创建(7)
- 2009-03-26 菜鸟寻“食”
- asp.net中数据链路层的创建(8)
- javaJDK 将int 转成32位的string
- asp.net中数据链路层的创建(9)
- ubuntu 实践
- Linux中的用户ID和有效用户ID的区别
- Ajax基本教程
- asp.net中数据链路层的创建(10)