📄 productpagebyparamcache.aspx
字号:
<%@ OutputCache Duration="300" VaryByParam="PID" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<Script Runat="Server">
Sub Page_Load( s As Object, e As EventArgs )
Dim strProductID As String
Dim conNorthwind As SqlConnection
Dim strSelect As String
Dim cmdSelect As SqlCommand
Dim dtrProducts As SqlDataReader
strProductID = Request.Params( "PID" )
If strProductID = Nothing Then
strProductID = "1"
End If
conNorthwind = New SqlConnection( "Server=Localhost;UID=sa;PWD=secret;Database=Northwind" )
strSelect = "Select * From Products Where ProductID=" & strProductID
cmdSelect = New SqlCommand( strSelect, conNorthwind )
conNorthwind.Open
dgrdProducts.DataSource = cmdSelect.ExecuteReader()
dgrdProducts.DataBind()
conNorthwind.Close
End Sub
</Script>
<html>
<head><title>ProductPageByParamCache.aspx</title></head>
<body>
<asp:DataGrid
ID="dgrdProducts"
CellPadding="10"
Runat="Server" />
<hr>
<small>Last Updated: <%=Now%></small>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -