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

    Sub Page_Load(sender As Object, e As EventArgs)
      BindGrid()
    End Sub

    Sub BindGrid()
      DataGrid1.DataSource = CreateDataTable()
      DataGrid1.DataBind()
    End Sub

    Function CreateDataTable() As DataTable
      Dim strSQL As String = "Select Top 10 * From Customers"
      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 da As New OleDbDataAdapter(strSQL, con)
      Dim dt As New DataTable()

      da.Fill(dt)
      Return(dt)
    End Function

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <h3>ビューステート無効（その１）</h3>
        <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" CellPadding="4" BackColor="White" BorderWidth="1px" BorderStyle="None" BorderColor="#3366CC">
            <FooterStyle forecolor="#003399" backcolor="#99CCCC"></FooterStyle>
            <SelectedItemStyle font-bold="True" forecolor="#CCFF99" backcolor="#009999"></SelectedItemStyle>
            <ItemStyle forecolor="#003399" backcolor="White"></ItemStyle>
            <HeaderStyle font-bold="True" horizontalalign="Center" forecolor="#CCCCFF" backcolor="#003399"></HeaderStyle>
            <Columns>
                <asp:BoundColumn DataField="CustomerID" HeaderText="ID">
                    <ItemStyle horizontalalign="Right"></ItemStyle>
                </asp:BoundColumn>
                <asp:BoundColumn DataField="CompanyName" HeaderText="得意先"></asp:BoundColumn>
            </Columns>
            <PagerStyle horizontalalign="Left" forecolor="#003399" backcolor="#99CCCC" mode="NumericPages"></PagerStyle>
        </asp:DataGrid>
    </form>
</body>
</html>
