📄 productpagebyparamcache.aspx
字号:
<%@ Page Language="C#" %>
<%@ OutputCache Duration="300" VaryByParam="PID" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat=server>
void Page_Load(Object sender , EventArgs e)
{
string strProductID;
SqlConnection conNorthwind;
string strSelect;
SqlCommand cmdSelect;
SqlDataReader dtrProducts;
strProductID = Request.Params[ "PID" ];
if ( strProductID == null )
{
strProductID = "1";
}
conNorthwind = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;Database=Northwind" );
strSelect = "Select * From Products Where ProductID=" + strProductID;
cmdSelect = new SqlCommand( strSelect, conNorthwind );
conNorthwind.Open();
dgrdProducts.DataSource = cmdSelect.ExecuteReader();
dgrdProducts.DataBind();
conNorthwind.Close();
}
</Script>
<html>
<head><title>ProductPageByParamCache.aspx</title></head>
<body>
<asp:DataGrid
ID="dgrdProducts"
CellPadding="10"
Runat="Server" />
<hr>
<small>Last Updated: <%=DateTime.Now%></small>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -