Simple DataList Demo

This demo illustrates how the DataList's RepeatColumns property can be used to display multiple DataSource records per HTML <table> row. Specifically, in this demo 5 records are shown per table row.

Source Code
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
  End Sub
  Sub BindData()
    '1. Create a connection
    Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))

    '2. Create the command object, passing in the SQL string
    Const strSQL as String = "sp_Popularity"
    Dim myCommand as New SqlCommand(strSQL, myConnection)

    'Set the datagrid's datasource to the datareader and databind
    rptULforFAQs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
  End Sub

<asp:Repeater runat="server" id="rptULforFAQs">
     <li><%# DataBinder.Eval(Container.DataItem, "Description")%></li>

[Return to the article]