home *** CD-ROM | disk | FTP | other *** search
ASP.NET Web Form | 2002-10-14 | 1.9 KB | 53 lines |
- <%@ Page Language="VB" Culture="nl-NL"%>
- <%@ import Namespace="System.Data" %>
- <%@ import Namespace="System.Data.SqlClient" %>
- <script runat="server">
-
- Dim ConnStr As String = "server=(local)\NetSdk;database=Northwind;trusted_connection=true"
- Dim CommandStr As String = "SELECT ProductID, ProductName, UnitPrice FROM Products"
-
- Sub Page_Load(Sender As Object, E As EventArgs)
- If Not Page.IsPostBack Then
- BindGrid()
- End If
- End Sub
-
- Sub BindGrid()
- Dim objConn As New SqlConnection(ConnStr)
- Dim objCmnd As New SqlDataAdapter(CommandStr, objConn)
- Dim objDs As New DataSet()
-
- objCmnd.Fill(objDs)
-
- Grid.DataSource = objDs
- Grid.DataBind()
- End Sub
-
- Sub ChangePage(source As Object, e As DataGridPageChangedEventArgs)
- Grid.CurrentPageIndex = e.NewPageIndex
- BindGrid()
- End Sub
-
- </script>
- <html>
- <head>
- </head>
- <body>
- <form runat="server">
- <asp:datagrid id="Grid" runat="server" AutoGenerateColumns="False" OnPageIndexChanged="ChangePage" AllowPaging="True" ForeColor="Black" BackColor="White" CellPadding="3" GridLines="None" CellSpacing="1">
- <HeaderStyle font-bold="True" forecolor="White" backcolor="#4A3C8C"></HeaderStyle>
- <PagerStyle nextpagetext="volgende" prevpagetext="vorige" pagebuttoncount="5" mode="NumericPages"></PagerStyle>
- <AlternatingItemStyle backcolor="#ABACAB"></AlternatingItemStyle>
- <ItemStyle backcolor="#DEDFDE"></ItemStyle>
- <Columns>
- <asp:BoundColumn DataField="ProductName"
- HeaderText="Productnaam"/>
- <asp:BoundColumn DataField="UnitPrice"
- HeaderText="Prijs" DataFormatString="{0:c}">
- </asp:BoundColumn>
- </Columns>
- </asp:datagrid>
- </form>
- </body>
- </html>
-