CheckBoxList.RepeatLayout プロパティ

定義

table 要素、ul 要素、ol 要素、span 要素のいずれを使用してリストを出力するかを指定する値を取得または設定します。

public:
 virtual property System::Web::UI::WebControls::RepeatLayout RepeatLayout { System::Web::UI::WebControls::RepeatLayout get(); void set(System::Web::UI::WebControls::RepeatLayout value); };
[System.ComponentModel.Bindable(true)]
public virtual System.Web.UI.WebControls.RepeatLayout RepeatLayout { get; set; }
public virtual System.Web.UI.WebControls.RepeatLayout RepeatLayout { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.RepeatLayout : System.Web.UI.WebControls.RepeatLayout with get, set
member this.RepeatLayout : System.Web.UI.WebControls.RepeatLayout with get, set
Public Overridable Property RepeatLayout As RepeatLayout

プロパティ値

table 要素、ul 要素、ol 要素、span 要素のいずれを使用してリストを出力するかを指定する値。 既定値は、Table です。

属性

例外

指定したレイアウトが、RepeatLayout 値ではありません。

次のコード例では、 プロパティを使用 RepeatLayout して、コントロールがレンダリングする HTML を変更する方法を CheckBoxList 示します。

注意

次のコード サンプルでは、単一ファイルのコード モデルを使用しており、分離コード ファイルに直接コピーすると正しく動作しない場合があります。 各コード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。 Web Forms コード モデルの詳細については、「ASP.NET Web Forms ページ コード モデル」を参照してください。


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

<!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> CheckBoxList RepeatLayout Example </title>
<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 id="form1" 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>

<%@ Page Language="VB" AutoEventWireup="True" %>

<!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> CheckBoxList RepeatLayout Example </title>
<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 id="form1" 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>

注釈

使用可能なオプションの詳細については、 列挙を RepeatLayout 参照してください。

注意

ASP.NET 4 OrderedList の時点では、 と の 2 つのオプションが新しまれています UnorderedList

一部の RepeatLayout 設定では、水平レイアウトが許可されていません。 詳細については、RepeatLayout 列挙型のページをご覧ください。

適用対象

こちらもご覧ください