<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title>DataList RepeatDirection Property</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server" src="fetchData_sql.cs"></script>
<script language="C#" runat="server">
void Page_Load ( Object src, EventArgs E ) {
if ( !IsPostBack ) {
string query = "SELECT CompanyName FROM Suppliers";
myList.DataSource = fetchData ( query );
myList.DataBind ( );
}
myList.RepeatColumns = setNumCols.SelectedIndex;
if ( setDirection.SelectedIndex == 0 )
myList.RepeatDirection = RepeatDirection.Horizontal;
else
myList.RepeatDirection = RepeatDirection.Vertical;
if ( ( setBorder.Checked ) && ( myList.RepeatLayout == RepeatLayout.Table ) ) {
myList.BorderWidth = Unit.Pixel ( 1 );
myList.GridLines = GridLines.Both;
}
else {
myList.BorderWidth = Unit.Pixel ( 0 );
myList.GridLines = GridLines.None;
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>DataList RepeatDirection Property</h2></div>
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<p>
RepeatColumns:
<asp:dropdownlist id="setNumCols" runat="server" autopostback>
<asp:listitem>0</asp:listitem>
<asp:listitem>1</asp:listitem>
<asp:listitem selected>2</asp:listitem>
<asp:listitem>3</asp:listitem>
<asp:listitem>4</asp:listitem>
<asp:listitem>5</asp:listitem>
</asp:dropdownlist>
RepeatDirection:
<asp:dropdownlist id="setDirection" runat="server" autopostback>
<asp:listitem>Horizontal</asp:listitem>
<asp:listitem selected>Vertical</asp:listitem>
</asp:dropdownlist>
Show Borders: <asp:checkbox id="setBorder" runat="server" checked autopostback />
</p>
<asp:datalist id="myList" runat="server"
width="92%" cellpadding=5 repeatcolumns=2
headerstyle-font-bold
headerstyle-backcolor="burlywood"
alternatingitemstyle-backcolor="ivory">
<headertemplate>
Suppliers
</headertemplate>
<itemtemplate>
<%# Eval ( "CompanyName" ) %>
</itemtemplate>
</asp:datalist>
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>