Friday, June 8, 2007

Simple ASPX Output from a Database

Here is something that seemed hard to find on the internet when I was trying to create some simple output out of .NET directly to javascript. This simple sample I came up with to remind me of how to do it for the future and maybe it can help you as well. All you would need to do is setup a database and change the script below to reference your instance of SQL Express.

<html xmlns="" >
<title>Simple Output
<form id="form1" runat="server">

<asp:Repeater ID="repeater1" runat="server"
<%# Eval("TimeText") %><br />

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
connectionString="Data Source=(YOUR_DATABASE_SERVER)\SQLEXPRESS;Initial
Catalog=(YOUR_DATABASE);Integrated Security=True;Pooling=False"
[TimeText],[TimeOrder] FROM [(YOUR_TABLE)] ORDER BY [TimeOrder]">