Displaying database content dynamically is one of the most common tasks in ASP.NET development. Using a SQL query with a DataTable and Repeater control enables developers to load and organize records directly from SQL Server on a webpage. This approach keeps the page structure cleaner, improves data handling, and makes it easier to manage repeating content such as lists, records, categories, or custom website data.
[ASP.NET - VB.NET Repeater (FrontEnd)]
CFFCS | CarrzSynEdit: | ASP.NET (VB/C#)
<asp:Repeater ID="rptList" runat="server">
	 <ItemTemplate>
        <span><%#Server.HtmlEncode(Eval("Col1").ToString()) %></span> | <span><%#Server.HtmlEncode(Eval("Col2").ToString()) %></span> | <span><%#Server.HtmlEncode(Eval("Col3").ToString()) %></span>

	 </ItemTemplate>	
    </asp:Repeater>

[ASP.NET - VB.NET Repeater (CodeBehind)]
CFFCS | CarrzSynEdit: | ASP.NET (VB/C#)
Protected Sub Page Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            LLoadList()
        End If
    End Sub


    Private Sub LoadList(Getid As Integer)
	        Dim dtList As New DataTable()
        Dim sql As String = "SELECT Col1, Col2, Col3 from Table1 where ColID = @ColID"

        Using conn As New SqlConnection(connStr)
            Using cmdList As New SqlCommand(sql, conn)
                cmdList.Parameters.Add("@ColID", SqlDbType.Int).Value = Getid
                Using daList As New SqlDataAdapter(cmdList)
                    daList.Fill(dtList)
                End Using
            End Using
        End Using

        rptList.DataSource = dtList
        rptList.DataBind()
  End Sub

Other Articles Related to this Entry.Loading SQL Server Data into an ASP.NET Repeater for C#.NET«