asp:datalist: repeat column, repeat directions, gridlines,
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
If Not IsPostBack Then
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection( _
"PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("EmployeeDatabase.mdb;"))
DBCommand = New OleDbDataAdapter _
("Select FirstName, LastName " _
& "From Employee " _
& "Order By FirstName", DBConn)
DBCommand.Fill(DSPageData, _
"Employee")
dlDepts.DataSource = _
DSPageData.Tables("Employee").DefaultView
dlDepts.DataBind()
End If
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Creating a Basic DataList Control</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<BR><BR>
<asp:datalist
id="dlDepts"
runat="server"
repeatcolumns=2
repeatdirection="Vertical"
repeatlayout="table"
gridlines="Both"
backcolor="lightyellow"
forecolor="darkred"
borderwidth=3
bordercolor="darkgreen"
>
<headerstyle
backcolor="darkred"
forecolor="lightyellow"
font-bold="true"
/>
<headertemplate>
Below is a list of all the employees.
</headertemplate>
<itemtemplate>
<%# "<B>Department:</B> " _
& DataBinder.Eval(Container.DataItem, "FirstName") _
& "<BR>" _
& DataBinder.Eval(Container.DataItem, "LastName")
%>
</itemtemplate>
<alternatingitemstyle
backcolor="lightgreen"
forecolor="darkblue"
/>
<alternatingitemtemplate>
<%# "<B>Department:</B> " _
& DataBinder.Eval(Container.DataItem, "FirstName") _
& "<BR>" _
& DataBinder.Eval(Container.DataItem, "LastName")
%>
</alternatingitemtemplate>
<separatortemplate>
***
</separatortemplate>
<footerstyle
backcolor="darkred"
forecolor="lightyellow"
font-bold="true"
/>
<footertemplate>
No more records found.
</footertemplate>
</asp:datalist>
</form>
</BODY>
</HTML>
EmployeeDatabase.zip( 10 k)Related examples in the same category