productpage.aspx

来自「asp.net技术内幕的书配源码」· ASPX 代码 · 共 44 行

ASPX
44
字号
<%@ Page Language="C#" %>
<%@ OutputCache Duration="300" VaryByParam="none" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script language="C#" runat=server>

void Page_Load(Object sender , EventArgs e) 
{
	SqlConnection conNorthwind;
	string  strSelect;
	SqlCommand cmdSelect;
	SqlDataReader dtrProducts;

	conNorthwind = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;Database=Northwind" );
	strSelect = "Select * From Products Where ProductID=1";
	cmdSelect = new SqlCommand( strSelect, conNorthwind );
	conNorthwind.Open();
	dgrdProducts.DataSource = cmdSelect.ExecuteReader( CommandBehavior.SingleRow );
	dgrdProducts.DataBind();
	conNorthwind.Close();

	string strTime = DateTime.Now.ToString();
	lblMessage.Text = strTime;
}
</Script>
<html>
<head><title>ProductPage.aspx</title></head>
<body>

<asp:DataGrid
  ID="dgrdProducts"
  CellPadding="10"
  Runat="Server" />
<hr>
<small>Last Updated: <asp:Label
  ID="lblMessage"
  Font-Bold="True"
  ForeColor="Blue"
  Runat="Server" /></small>

</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?