ObjectListCommandとは? わかりやすく解説

ObjectListCommand クラス

ObjectList ASP.NET モバイル コントロール内のコマンドを表します。

名前空間: System.Web.UI.MobileControls
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)
構文構文

Public Class ObjectListCommand
Dim instance As ObjectListCommand
public class ObjectListCommand
public ref class ObjectListCommand
public class ObjectListCommand
public class ObjectListCommand
解説解説

ObjectListCommand オブジェクトは、ObjectList の宣言内で <command> 要素として宣言できます。

また、ObjectListCommand オブジェクトをコントロールの Commands メンバ コレクションに追加して構築し、プログラムによって ObjectList コントロールに追加することもできます。

使用例使用例

ObjectListCommand オブジェクトを作成する方法の例を次に示します。このコード例は、ObjectList の概要で取り上げている詳しいコード例の一部です。

<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage"
 %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls"
 
    Assembly="System.Web.Mobile"
 %>

<script runat="server">
    ' System.Web.UI.MobileControls.ObjectListItem item
    ' System.Web.UI.MobileControls.ObjectListItemCollection itemColl
    ' Get the persisted array through postbacks.
    Private arr As New ArrayList()
    Public Sub Page_Load(ByVal
 sender As Object, ByVal
 e As EventArgs)
        If Not IsPostBack Then
            ' Create and fill the array
            arr.Add(new Task("Tomorrow's work",
 "Yes", 1))
            arr.Add(new Task("Today's work",
 "Yes", 1))
            arr.Add(new Task("Yesterday's work",
 "No", 1))
            
            ' Persist the array in the Session object
            Session("MyArrayList") = arr

            ' Associate and bind array to the 
            ' ObjectList for each postback.
            ObjectList1.DataSource = arr
            ObjectList1.LabelField = "TaskName"
            ObjectList1.DataBind()
            
        End If
    End Sub

    Private Sub SelectCommand(ByVal
 sender As Object, _
         ByVal e As ObjectListCommandEventArgs)
        ' Get the array from the Session object
        arr = CType(Session("MyArrayList"), ArrayList)

        ' Remove selected item from the ObjectLis
        Dim i As Integer
 = ObjectList1.SelectedIndex
        arr.RemoveAt(i)
        Session("MyArrayList") = arr

        ' Re-Bind ObjectList to altered ArrayList.
        ObjectList1.DataSource = arr
        ObjectList1.LabelField = "TaskName"
        ObjectList1.DataBind()
        ObjectList1.ViewMode = ObjectListViewMode.List
    End Sub

    Public Sub ShowTaskDetail(ByVal
 sender As Object, _
        ByVal e As ObjectListShowCommandsEventArgs)

        ' Check conditions, and add or remove 
        ' commands in the detail view.
        If e.ListItem("Editable").Equals("No")
 Then
            ObjectList1.Commands.RemoveAt(0)
        ElseIf ObjectList1.Commands.Count < 1 Then
            ObjectList1.Commands.Add(New ObjectListCommand("Delete",
 "Delete"))
        End If
    End Sub

    Private Class Task
        Private _TaskName As String
        Private _Editable As String
        Private _Days As Integer
        Public Sub New(ByVal
 TaskName As String, _
            ByVal Editable As String,
 ByVal Days As Integer)

            _TaskName = TaskName
            _Editable = Editable
            _Days = Days
        End Sub
        Public ReadOnly Property
 TaskName() As String
            Get
                Return _TaskName
            End Get
        End Property
        Public ReadOnly Property
 Editable() As String
            Get
                Return _Editable
            End Get
        End Property
        Public ReadOnly Property
 Days() As Integer
            Get
                Return _Days
            End Get
        End Property
    End Class
</script>

<html xmlns="http:'www.w3.org/1999/xhtml" >
<body>
    <mobile:Form runat="server" id="Form1"
 >
        <mobile:ObjectList runat="server" id="ObjectList1"
 
            OnItemCommand="SelectCommand" OnShowItemCommands="ShowTaskDetail"
 >
            <Command Name="Delete" Text="Delete"
 />
        </mobile:ObjectList>
        <mobile:Label runat="server" id="Label1"
 />
        <mobile:Label runat="server" id="Label2"
 />
    </mobile:Form>
</body>
</html>
<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    //System.Web.UI.MobileControls.ObjectListItem item;
    //System.Web.UI.MobileControls.ObjectListItemCollection itemColl;
    // Get the persisted array through postbacks.
    ArrayList arr = new ArrayList();
    public void Page_Load(Object sender, EventArgs
 e)
    {
        if (!IsPostBack)
        {
            // Create and fill the array
            arr.Add(new Task("Tomorrow's work", "Yes",
 1));
            arr.Add(new Task("Today's work", "Yes",
 1));
            arr.Add(new Task("Yesterday's work", "No",
 1));
            
            // Persist the array in the Session object
            Session["MyArrayList"] = arr;

            // Associate and bind array to the 
            // ObjectList for each postback.
            ObjectList1.DataSource = arr;
            ObjectList1.LabelField = "TaskName";
            ObjectList1.DataBind();
        }
    }

    private void ItemCommand_Click(Object sender,
 
        ObjectListCommandEventArgs e)
    {
        // Get the array from the Session object
        arr = (ArrayList)Session["MyArrayList"];

        // Remove selected item from the ObjectLis
        int i = ObjectList1.SelectedIndex;
        arr.RemoveAt(i);
        Session["MyArrayList"] = arr;

        // Re-Bind ObjectList to altered ArrayList.
        ObjectList1.DataSource = arr;
        ObjectList1.LabelField = "TaskName";
        ObjectList1.DataBind();
        ObjectList1.ViewMode = ObjectListViewMode.List;
    }

    void ItemCommands_Show(Object sender, 
        ObjectListShowCommandsEventArgs e) 
    {
        // Check conditions, and add or remove 
        // commands in the detail view.
        if (e.ListItem["Editable"].Equals("No"))
            ObjectList1.Commands.RemoveAt(0);
        else if (ObjectList1.Commands.Count
 < 1)
            ObjectList1.Commands.Add(new 
                ObjectListCommand("Delete", "Delete"));
    }

    private class Task
    {
        private string _TaskName;
        private string _Editable;
        private int _Days;
        public Task(string TaskName, string
 Editable, int Days)
        {
            _TaskName = TaskName;
            _Editable = Editable;
            _Days = Days;
        }
        public string TaskName
        { get { return _TaskName; } }
        public string Editable
        { get { return _Editable; } }
        public int Days
        { get { return _Days; } }
    }
</script>

<html  >
<body>
    <mobile:Form runat="server" id="Form1" >
        <mobile:ObjectList runat="server" id="ObjectList1"
 
            OnItemCommand="ItemCommand_Click" 
            OnShowItemCommands="ItemCommands_Show" >
            <Command Name="Delete" Text="Delete" />
        </mobile:ObjectList>
        <mobile:Label runat="server" id="Label1" />
        <mobile:Label runat="server" id="Label2" />
    </mobile:Form>
</body>
</html>
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.MobileControls.ObjectListCommand
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ObjectListCommand メンバ
System.Web.UI.MobileControls 名前空間
その他の技術情報
ObjectList コントロールの概要

ObjectListCommand コンストラクタ ()


ObjectListCommand コンストラクタ (String, String)

ObjectListCommand クラスの新しいインスタンスを初期化します。

名前空間: System.Web.UI.MobileControls
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)
構文構文

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ObjectListCommand クラス
ObjectListCommand メンバ
System.Web.UI.MobileControls 名前空間
その他の技術情報
ObjectList コントロールの概要

ObjectListCommand コンストラクタ

ObjectListCommand クラスの新しいインスタンスを初期化します。 ObjectList コントロールの概要
オーバーロードの一覧オーバーロードの一覧

名前 説明
ObjectListCommand () ObjectListCommand クラスの新しいインスタンスを初期化します。
ObjectListCommand (String, String) ObjectListCommand クラスの新しいインスタンスを初期化します。
参照参照

関連項目

ObjectListCommand クラス
ObjectListCommand メンバ
System.Web.UI.MobileControls 名前空間

その他の技術情報

ObjectList コントロールの概要
ObjectList コントロールの概要

ObjectListCommand プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

ObjectListCommand クラス
System.Web.UI.MobileControls 名前空間

その他の技術情報

ObjectList コントロールの概要

ObjectListCommand メソッド


ObjectListCommand メンバ

ObjectList ASP.NET モバイル コントロール内のコマンドを表します。

ObjectListCommand データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド ObjectListCommand オーバーロードされます。 ObjectListCommand クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ObjectListCommand クラス
System.Web.UI.MobileControls 名前空間

その他の技術情報

ObjectList コントロールの概要



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「ObjectListCommand」の関連用語

ObjectListCommandのお隣キーワード

   

英語⇒日本語
日本語⇒英語
   



ObjectListCommandのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS