CheckBoxList RepeatLayout Table in asp.net c#

CheckBoxList RepeatLayout Table
The following asp.net c# example code demonstrate us how can we set or change CheckBoxList RepeatLayout programmatically at run time. CheckBoxList is an asp.net list web server control. CheckBoxList RepeatColumns property allow us to get or set the number of columns to display in the CheckBoxList. ChekBoxList RepeatLayout property allow us to get or set a value that indicate whether the list will be rendered as a html 'table' element, a 'ul' element, an 'ol' element or a 'span' element.

We can set CheckBoxList RepeatLayout property value by selecting a value from RepeatLayout enumeration. RepeatLayout enumeration have four possible values those are Flow, OrderedList, Table and UnorderedList. Table type RepeatLayout render a CheckBoxList control as a html table element. Then CheckBoxList control manage RepeatColumns by table td element and it put all of its items in table separate cell.
CheckBoxListRepeatLayoutTable.aspx

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        CheckBoxList1.RepeatLayout = RepeatLayout.Table;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to use CheckBoxList RepeatLayout Table in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:DarkOliveGreen; font-style:italic;">
            How to use CheckBoxList
            <br /> RepeatLayout Table in asp.net
        </h2>
        <hr width="475" align="left" color="DarkKhaki" />
        <asp:CheckBoxList
             ID="CheckBoxList1"
             runat="server"
             Font-Size="Large"
             Font-Underline="true"
             Font-Names="Courier New"
             Font-Italic="true"
             ForeColor="Maroon"
             Font-Bold="true"
             RepeatLayout="Flow"
             Width="475"
             BorderWidth="1"
             BorderColor="Magenta"
             RepeatColumns="2"
             >
             <asp:ListItem Text="Picea sitchensis"></asp:ListItem>
             <asp:ListItem Text="Populus alba"></asp:ListItem>
             <asp:ListItem Text="Hippophae rhamnoides"></asp:ListItem>
             <asp:ListItem Text="Hawthorn"></asp:ListItem>
             <asp:ListItem Text="Acer platanoides"></asp:ListItem>
        </asp:CheckBoxList>
        <br />
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Set CheckBoxList RepeatLayout Table"
            Height="45"
            Font-Bold="true"
            ForeColor="DodgerBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples