Here's a suggestion for tackling this challenge. Let's assume that the number of items to display vertically before wrapping can be predetermined by the server, rather than being dependent on the user's browser height.
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
rptVerticalWrap.DataSource = new[] {
new { ID = 1, Name = "ABC" },
new { ID = 2, Name = "BCD" },
new { ID = 3, Name = "CDE" },
new { ID = 4, Name = "DEF" },
new { ID = 5, Name = "EFG" },
new { ID = 6, Name = "FGH" },
new { ID = 7, Name = "GHI" },
new { ID = 8, Name = "HIJ" },
};
rptVerticalWrap.DataBind();
}
int count;
const int VerticalWrapLimit = 5;
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<% count = 0; %>
<div style="float:left;">
<asp:Repeater ID="rptVerticalWrap" runat="server">
<ItemTemplate>
<%
if (count % VerticalWrapLimit == 0 && count > 0)
{
%></div><div style="float:left;"><%
}
count++;
%>
<div>
<asp:Label runat="server" Text="ID: " /><asp:TextBox runat="server" Text='<%# Eval("ID") %>' />
<asp:Label runat="server" Text="Name: " /><asp:TextBox runat="server" Text='<%# Eval("Name") %>' />
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
</form>
</body>
</html>
In approaching a problem like this, it's important to envision the desired HTML structure first and then craft the ASP code to generate it accordingly.
In this scenario, each vertical column of data is enclosed in a div element with the style attribute set to "float:left;". The use of a class-scoped "count" variable helps in determining when to close off the current div and initiate a new one. It should be noted that the count variable must be declared at the class level due to scope differences within the Repeater's ItemTemplate compared to the rest of the page.