datalist and ItemTemplate
<%@ Page %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Const strConnString as String = "server=localhost;uid=sa;pwd=;database=pubs"
Dim objConn as New SqlConnection(strConnString)
Const strSQL as String = "SELECT * FROM authors"
Dim objCmd as New SqlCommand(strSQL, objConn)
Dim objDA as New SqlDataAdapter()
objDA.SelectCommand = objCmd
Dim objDS as New DataSet()
objDA.Fill(objDS)
objConn.Close()
dlAuthors.DataSource = objDS
dlAuthors.DataBind()
End Sub
</script>
<asp:datalist id="dlAuthors" runat="server"
RepeatColumns="4">
<ItemTemplate>
<b><%# DataBinder.Eval(Container.DataItem, "au_lname") %>,
<%# DataBinder.Eval(Container.DataItem, "au_fname") %></b>
</ItemTemplate>
</asp:datalist>
Related examples in the same category