ASP 101 - Active Server Pages 101 db_highlight.aspx
<%@ Page Language="VB" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SQLClient" %>
<script language="VB" runat="server">
    Sub Page_Load(sender As Object, e As EventArgs)
        Dim myConnection  As SqlConnection 
        Dim myCommand     As SqlCommand
		myConnection = New SqlConnection("Data Source=10.2.2.133;" _
			& "Initial Catalog=samples;User Id=samples;Password=password;" _
			& "Connect Timeout=15;Network Library=dbmssocn;")
        myCommand = New SqlCommand("SELECT * FROM scratch;", myConnection)
        ' Open connection, execute reader, and databind to the results.
        myConnection.Open()
        HighlightRepeater.DataSource = myCommand.ExecuteReader( _
            CommandBehavior.CloseConnection)
        HighlightRepeater.Databind()
    End Sub
</script>
<html>
<head>
<title>ASP.NET Database Highlight Sample</title>
</head>
<body>
<form runat="server" EnableViewState="false">
<asp:Repeater id="HighlightRepeater" runat="server">
    <HeaderTemplate>
        <table border="1" cellspacing="2">
            <tr bgcolor="#C0C0C0">
                <td><strong>id</strong></td>
                <td><strong>text_field</strong></td>
                <td><strong>integer_field</strong></td>
                <td><strong>date_time_field</strong></td>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
            <tr bgcolor="#FFFFFF" onMouseOver="this.bgColor='#FFFF00'" onMouseOut="this.bgColor='#FFFFFF'">
                <td><%# DataBinder.Eval(Container.DataItem, "id") %></td>
                <td><%# DataBinder.Eval(Container.DataItem, "text_field") %></td>
                <td><%# DataBinder.Eval(Container.DataItem, "integer_field") %></td>
                <td><%# DataBinder.Eval(Container.DataItem, "date_time_field") %></td>
            </tr>
    </ItemTemplate>
    <AlternatingItemTemplate>
            <tr bgcolor="#CCCCFF" onMouseOver="this.bgColor='#FFFF00'" onMouseOut="this.bgColor='#CCCCFF'">
                <td><%# DataBinder.Eval(Container.DataItem, "id") %></td>
                <td><%# DataBinder.Eval(Container.DataItem, "text_field") %></td>
                <td><%# DataBinder.Eval(Container.DataItem, "integer_field") %></td>
                <td><%# DataBinder.Eval(Container.DataItem, "date_time_field") %></td>
            </tr>
    </AlternatingItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>
</form>
<hr />
<p>
Click <a href="http://www.asp101.com/samples/db_highlight_aspx.asp">here</a>
to read about and download the source code.
</p>
</body>
</html>