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 - C#.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 - C#.NET Repeater (CodeBehind)]
CFFCS | CarrzSynEdit: | ASP.NET (VB/C#)
protected void Page Load(object sender, EventArgs e)
(
    if (!IsPostBack)
    (
        LoadList();
    )
)

private void LoadList(int Getid)
(
    DataTable dtList = new DataTable();

    string sql = "SELECT Col1, Col2, Col3 FROM Table1 WHERE ColID = @ColID";

    using (SqlConnection conn = new SqlConnection(connStr))
    (
        using (SqlCommand cmdList = new SqlCommand(sql, conn))
        (
            cmdList.Parameters.Add("@ColID", SqlDbType.Int).Value = Getid;

            using (SqlDataAdapter daList = new SqlDataAdapter(cmdList))
            (
                daList.Fill(dtList);
            )
        )
    )

    rptList.DataSource = dtList;
    rptList.DataBind();
)

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