<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

    Sub Page_Load(sender As Object, e As EventArgs)
      If Not IsPostBack Then
        BindGrid()
      End If
    End Sub
    
    
    Sub BindGrid()
      Dim strSQL As String = "Select * From Categories"
    
      With DataGrid1
        .DataKeyField = "CategoryID"
        .DataSource = CreateDataReader(strSQL)
        .DataBind()
      End With
    End Sub
    
    Function CreateDataReader(strSQL As String) As OleDbDataReader
      Dim strConnectionString As String = _
        String.Format("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source={0}", _
          Server.MapPath("webdb/Nwind.mdb"))
      Dim con As New OleDbConnection(strConnectionString)
      Dim cmd As New OleDbCommand(strSQL, con)
    
      con.Open()
      Return cmd.ExecuteReader(CommandBehavior.CloseConnection)
    End Function

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <h3>ページレベルのキャッシュ（その２）</h3>
        <table>
            <tbody>
                <tr>
                    <td>
                        <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" CellPadding="4" BackColor="White" BorderColor="#336666" BorderWidth="3px" GridLines="Horizontal" BorderStyle="Double">
                            <FooterStyle forecolor="#333333" backcolor="White"></FooterStyle>
                            <HeaderStyle font-bold="True" forecolor="White" backcolor="#336666"></HeaderStyle>
                            <PagerStyle horizontalalign="Center" forecolor="White" backcolor="#336666" mode="NumericPages"></PagerStyle>
                            <SelectedItemStyle font-bold="True" forecolor="White" backcolor="#339966"></SelectedItemStyle>
                            <ItemStyle forecolor="#333333" backcolor="White"></ItemStyle>
                            <Columns>
                                <asp:BoundColumn DataField="CategoryID" HeaderText="ID"></asp:BoundColumn>
                                <asp:HyperLinkColumn Target="productFrame" DataNavigateUrlField="CategoryID" DataNavigateUrlFormatString="OutputCache2Products.aspx?categoryid={0}" DataTextField="CategoryName" HeaderText="商品区分名"></asp:HyperLinkColumn>
                            </Columns>
                        </asp:DataGrid>
                    </td>
                    <td>
                        <iframe id="productFrame" name="productFrame" frameborder="0" height="100%">
                        </iframe>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>
