CheckBoxList.RepeatLayout Property
Gets or sets the layout of the check boxes.
[Visual Basic] Public Overridable Property RepeatLayout As RepeatLayout [C#] public virtual RepeatLayout RepeatLayout {get; set;} [C++] public: __property virtual RepeatLayout get_RepeatLayout(); public: __property virtual void set_RepeatLayout(RepeatLayout); [JScript] public function get RepeatLayout() : RepeatLayout; public function set RepeatLayout(RepeatLayout);
Property Value
One of the RepeatLayout values. The default is Table.
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentException | The specified layout is not one of the RepeatLayout values. |
Remarks
Use this property to specify whether the items in the CheckBoxList control are displayed in a table. If this property is set to RepeatLayout.Table, the items in the list are displayed in a table. If this property is set to RepeatLayout.Flow, the items in the list are displayed without a table structure.
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the RepeatLayout property to display the CheckBoxList control without a table structure.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub Check_Clicked(sender As Object, e As EventArgs) Dim i As Integer Message.Text = "Selected Item(s):<br><br>" For i=0 To checkboxlist1.Items.Count - 1 If checkboxlist1.Items(i).Selected Then Message.Text += checkboxlist1.Items(i).Text + "<br>" End If Next End Sub </script> </head> <body> <form action="checkboxlist.aspx" method="post" runat="server"> <h3>CheckBoxList Example</h3> <asp:CheckBoxList id="checkboxlist1" AutoPostBack="True" CellPadding="5" CellSpacing="5" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Flow" TextAlign="Right" OnSelectedIndexChanged="Check_Clicked" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:CheckBoxList> <br><br> <asp:label id="Message" runat="server"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void Check_Clicked(Object sender, EventArgs e) { Message.Text = "Selected Item(s):<br><br>"; for (int i=0; i<checkboxlist1.Items.Count; i++) { if (checkboxlist1.Items[i].Selected) Message.Text += checkboxlist1.Items[i].Text + "<br>"; } } </script> </head> <body> <form action="checkboxlist.aspx" method="post" runat="server"> <h3>CheckBoxList Example</h3> <asp:CheckBoxList id="checkboxlist1" AutoPostBack="True" CellPadding="5" CellSpacing="5" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Flow" TextAlign="Right" OnSelectedIndexChanged="Check_Clicked" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:CheckBoxList> <br><br> <asp:label id="Message" runat="server"/> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> <script language="JScript" runat="server"> function Check_Clicked(sender : Object, e : EventArgs) { Message.Text = "Selected Item(s):<br><br>"; for (var i : int = 0; i<checkboxlist1.Items.Count; i++) { if (checkboxlist1.Items[i].Selected) Message.Text += checkboxlist1.Items[i].Text + "<br>"; } } </script> </head> <body> <form action="checkboxlist.aspx" method="post" runat="server"> <h3>CheckBoxList Example</h3> <asp:CheckBoxList id="checkboxlist1" AutoPostBack="True" CellPadding="5" CellSpacing="5" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Flow" TextAlign="Right" OnSelectedIndexChanged="Check_Clicked" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:CheckBoxList> <br><br> <asp:label id="Message" runat="server"/> </form> </body> </html> [Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Sub Check_Clicked(sender as Object, e As EventArgs) Message.Text = "Selected Item(s):<br><br>" ' Iterate through the Items collection of the CheckBoxList ' control and display the selected items. Dim i As Integer For i=0 To checkboxlist1.Items.Count - 1 If checkboxlist1.Items(i).Selected Then Message.Text &= checkboxlist1.Items(i).Text & "<br>" End If Next End Sub Sub Index_Change(sender as Object, e As EventArgs) ' Set the layout (table or flow) of the CheckBoxList control. checkboxlist1.RepeatLayout = CType(List.SelectedIndex, RepeatLayout) End Sub </script> </head> <body> <form runat="server"> <h3> CheckBoxList RepeatLayout Example </h3> Select items from the CheckBoxList. <br><br> <asp:CheckBoxList id="checkboxlist1" AutoPostBack="True" CellPadding="5" CellSpacing="5" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Table" TextAlign="Right" OnSelectedIndexChanged="Check_Clicked" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:CheckBoxList> <br><br> <asp:label id="Message" runat="server"/> <hr> Select whether to display the CheckBoxList control in table or flow layout. <table cellpadding="5"> <tr> <td> RepeatLayout: </td> </tr> <tr> <td> <asp:DropDownList id="List" AutoPostBack="True" OnSelectedIndexChanged="Index_Change" runat="server"> <asp:ListItem Selected="True">Table</asp:ListItem> <asp:ListItem>Flow</asp:ListItem> </asp:DropDownList> </td> </tr> </table> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script runat="server"> void Check_Clicked(Object sender, EventArgs e) { Message.Text = "Selected Item(s):<br><br>"; // Iterate through the Items collection of the CheckBoxList // control and display the selected items. for (int i=0; i<checkboxlist1.Items.Count; i++) { if (checkboxlist1.Items[i].Selected) { Message.Text += checkboxlist1.Items[i].Text + "<br>"; } } } void Index_Change(Object sender, EventArgs e) { // Set the layout (table or flow) of the CheckBoxList control. checkboxlist1.RepeatLayout = (RepeatLayout)List.SelectedIndex; } </script> </head> <body> <form runat="server"> <h3> CheckBoxList RepeatLayout Example </h3> Select items from the CheckBoxList. <br><br> <asp:CheckBoxList id="checkboxlist1" AutoPostBack="True" CellPadding="5" CellSpacing="5" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Table" TextAlign="Right" OnSelectedIndexChanged="Check_Clicked" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:CheckBoxList> <br><br> <asp:label id="Message" runat="server"/> <hr> Select whether to display the CheckBoxList control in table or flow layout. <table cellpadding="5"> <tr> <td> RepeatLayout: </td> </tr> <tr> <td> <asp:DropDownList id="List" AutoPostBack="True" OnSelectedIndexChanged="Index_Change" runat="server"> <asp:ListItem Selected="True">Table</asp:ListItem> <asp:ListItem>Flow</asp:ListItem> </asp:DropDownList> </td> </tr> </table> </form> </body> </html>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
CheckBoxList Class | CheckBoxList Members | System.Web.UI.WebControls Namespace | RepeatColumns | RepeatDirection