ListControl.Items プロパティ
アセンブリ: System.Web (system.web.dll 内)

リストの項目を表す ListItemCollection。既定値は空のリストです。


Items プロパティを使用して、CheckBoxList コントロールで選択された項目を決定する方法を次の例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> </head> <body> <script language="VB" runat="server"> Sub Check_Clicked(sender As Object, e As EventArgs) Message.Text = "Selected Item(s):<br><br>" Dim i As Integer For i = 0 To checkboxlist1.Items.Count - 1 If checkboxlist1.Items(i).Selected Then Message.Text = Message.Text & checkboxlist1.Items(i).Text & "<br>" End If Next End Sub </script> <form method="post" runat="server"> <asp:CheckBoxList id="checkboxlist1" runat="server" AutoPostBack="True" CellPadding="5" CellSpacing="5" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Flow" TextAlign="Right" OnSelectedIndexChanged="Check_Clicked"> <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>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> </head> <body> <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=Message.Text + checkboxlist1.Items[i].Text + "<br>"; } } </script> <form method="post" runat="server"> <asp:CheckBoxList id="checkboxlist1" runat="server" AutoPostBack="True" CellPadding="5" CellSpacing="5" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Flow" TextAlign="Right" OnSelectedIndexChanged="Check_Clicked"> <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>
<%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> </head> <body> <script language="JSCRIPT" runat="server"> function Check_Clicked(sender : Object, e : EventArgs){ Message.Text = "Selected Item(s):<br><br>" for(var i = 0; i < checkboxlist1.Items.Count; i++){ if(checkboxlist1.Items(i).Selected) Message.Text = Message.Text + checkboxlist1.Items(i).Text + "<br>" } } </script> <form method="post" runat="server"> <asp:CheckBoxList id="checkboxlist1" runat="server" AutoPostBack="True" CellPadding="5" CellSpacing="5" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Flow" TextAlign="Right" OnSelectedIndexChanged="Check_Clicked"> <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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からListControl.Items プロパティを検索する場合は、下記のリンクをクリックしてください。

- ListControl.Items プロパティのページへのリンク