ObjectList イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | ItemCommand | ObjectList 項目に関連付けられているコマンドをユーザーが選択すると発生します。 |
![]() | ItemDataBind | ObjectList 内の項目がデータにバインドされたときに発生します。 |
![]() | ItemSelect | ユーザーがリスト ビューから項目を選択した場合に発生します。 |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | LoadItems | コントロールの改ページ位置が自動修正され、さらにデータを必要とする場合に発生します。 ( PagedControl から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | ShowItemCommands | ObjectList 内の項目に関連付けられたコマンドが表示される前に発生します。 |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |

ObjectList クラス
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)

Public Class ObjectList Inherits PagedControl Implements INamingContainer, ITemplateable, IPostBackEventHandler
public ref class ObjectList : public PagedControl, INamingContainer, ITemplateable, IPostBackEventHandler

ObjectList には、デバイス テンプレート セットを通したテンプレート レンダリングのサポートや内部的な改ページ位置自動修正などの動作がありますが、その多くは List の動作に似ています。詳細については、「ObjectList コントロールの概要」または「改ページ調整」を参照してください。

ユーザー定義クラスの配列を作成し、ページの読み込み時にその配列を ObjectList オブジェクトにバインドする方法を次のコード例に示します。また、リスト ビューと詳細ビューにコマンドを表示する方法も示しています。この例には、AllFields プロパティを使用してすべてのフィールドのリストを含むフォームを表示するボタンもあります。
![]() |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。詳細については、「ASP.NET Web ページのコード モデル」を参照してください。 |
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <script runat="server"> Dim bakeryCount, dairyCount, produceCount As Integer Private Sub Page_Load(ByVal o As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Create an array and bind it to the list Dim arr As New ArrayList() arr.Add(New GroceryItem _ ("Bakery", "Rolls", "On Sale")) arr.Add(New GroceryItem _ ("Dairy", "Eggnog", "Half price")) arr.Add(New GroceryItem _ ("Produce", "Apples", _ "A dollar a bushel")) arr.Add(New GroceryItem _ ("Bakery", "Bread", "On Sale")) List1.DataSource = arr List1.DataBind() ' To show only one field on opening page, ' comment the next line List1.TableFields = "Item;Department" List1.LabelField = "Department" ' Display a report after items are databound Const txt As String = "Number of items by Department<br>Produce: " + _ "{0}<br />Dairy: {1}<br />Bakery: {2}" TextView2.Text = String.Format(txt, produceCount, dairyCount, bakeryCount) End If End Sub ' Command event for buttons Private Sub List1_Click(ByVal sender As Object, _ ByVal e As ObjectListCommandEventArgs) If e.CommandName = "Reserve" Then ActiveForm = Form2 ElseIf e.CommandName = "Buy" Then ActiveForm = Form3 Else ActiveForm = Form4 End If End Sub ' Count items in each department Private Sub List1_ItemDataBind(ByVal sender As Object, ByVal e As ObjectListDataBindEventArgs) Select Case CType(e.DataItem, GroceryItem).Department Case "Bakery" bakeryCount += 1 Case "Dairy" dairyCount += 1 Case "Produce" produceCount += 1 End Select End Sub Private Sub AllFields_Click(ByVal sender As Object, ByVal e As EventArgs) ActiveForm = Form5 Dim spec As String = "{0}: {1}<br/>" Dim flds As IObjectListFieldCollection = List1.AllFields Dim i As Integer For i = 0 To flds.Count - 1 TextView1.Text += _ String.Format(spec, (i + 1), flds(i).Title) Next End Sub ' Structure for ArrayList records Private Class GroceryItem ' A private class for the Grocery List Private _department, _item, _status As String Public Sub New(ByVal department As String, _ ByVal item As String, ByVal status As String) _department = department _item = item _status = status End Sub Public ReadOnly Property Department() As String Get Return _department End Get End Property Public ReadOnly Property Item() As String Get Return _item End Get End Property Public ReadOnly Property Status() As String Get Return _status End Get End Property End Class </script> <html > <body> <mobile:Form id="Form1" runat="server" BackColor="LightBlue"> <mobile:ObjectList id="List1" runat="server" OnItemCommand="List1_Click" OnItemDataBind="List1_ItemDataBind"> <DeviceSpecific ID="DeviceSpecific1" Runat="server"> <!-- See Web.config for filters --> <Choice Filter="isWML11" CommandStyle-Font-Bold="NotSet" /> <Choice CommandStyle-Font-Bold="true" CommandStyle-Font-Name="Arial" /> </DeviceSpecific> <Command Name="Reserve" Text="Reserve" /> <Command Name="Buy" Text="Buy" /> </mobile:ObjectList> <mobile:Command ID="AllFieldsCmd" Runat="server" OnClick="AllFields_Click"> List All Fields</mobile:Command> <mobile:TextView ID="TextView2" Runat="server" /> </mobile:Form> <mobile:Form id="Form2" runat="server" BackColor="LightBlue"> <mobile:Label id="ResLabel" runat="server" text="Sale item reservation system coming soon!" /> <mobile:Link id="ResLink" NavigateURL="#Form1" runat="server" text="Return" /> </mobile:Form> <mobile:Form id="Form3" runat="server" BackColor="LightBlue"> <mobile:Label id="BuyLabel" runat="server" Text="Online purchasing system coming soon!" /> <mobile:Link ID="BuyLink" NavigateURL="#Form1" Runat="server" text="Return" /> </mobile:Form> <mobile:Form id="Form4" Runat="server" BackColor="LightBlue"> <mobile:Label ID="DefLabel" Runat="server" Text="Detailed item descriptions will be here soon!"/> <mobile:Link ID="DefLink" NavigateURL="#Form1" Runat="server" Text="Return" /> </mobile:Form> <mobile:Form ID="Form5" Runat="server"> <mobile:Label ID="Label1" Runat="server"> List of AllFields:</mobile:Label> <mobile:TextView ID="TextView1" Runat="server" /> <mobile:Link ID="Link1" Runat="server" NavigateUrl="#Form1" Text="Return"></mobile:Link> </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"> int bakeryCount = 0, dairyCount = 0, produceCount = 0; public void Page_Load(Object o, EventArgs e) { if (!IsPostBack) { // Create an array and bind it to the list ArrayList arr = new ArrayList(); arr.Add (new GroceryItem ("Bakery", "Rolls", "On Sale")); arr.Add (new GroceryItem ("Dairy", "Eggnog", "Half price")); arr.Add (new GroceryItem ("Produce", "Apples", "A dollar a bushel")); arr.Add (new GroceryItem ("Bakery", "Bread", "On Sale")); List1.DataSource = arr; List1.DataBind (); // To show only one field on opening page, // comment the next line List1.TableFields = "Item;Department"; List1.LabelField = "Department"; // Display a report after items are databound string txt = "Number of items by Department<br>Produce: {0}<br />" + "Dairy: {1}<br />Bakery: {2}"; TextView2.Text = String.Format(txt, produceCount, dairyCount, bakeryCount); } } // Command event for buttons public void List1_Click(Object sender, ObjectListCommandEventArgs e) { if (e.CommandName == "Reserve") ActiveForm = Form2; else if (e.CommandName == "Buy") ActiveForm = Form3; else ActiveForm = Form4; } // Count items in each department private void List1_ItemDataBind(object sender, ObjectListDataBindEventArgs e) { switch (((GroceryItem)e.DataItem).Department) { case "Bakery": bakeryCount++; break; case "Dairy": dairyCount++; break; case "Produce": produceCount++; break; } } private void AllFields_Click(object sender, EventArgs e) { ActiveForm = Form5; string spec = "{0}: {1}<br/>"; IObjectListFieldCollection flds = List1.AllFields; for (int i = 0; i < flds.Count; i++) TextView1.Text += String.Format(spec, (i + 1), flds[i].Title); } // Structure for ArrayList records private class GroceryItem { // A private class for the Grocery List private String _department, _item, _status; public GroceryItem(string department , string item, string status) { _department = department; _item = item; _status = status; } public String Department { get { return _department; } } public String Item { get { return _item; } } public String Status { get { return _status; } } } </script> <html > <body> <mobile:Form id="Form1" runat="server" BackColor="LightBlue"> <mobile:ObjectList id="List1" runat="server" OnItemCommand="List1_Click" OnItemDataBind="List1_ItemDataBind"> <DeviceSpecific ID="DeviceSpecific1" Runat="server"> <!-- See Web.config for filters --> <Choice Filter="isWML11" CommandStyle-Font-Bold="NotSet" /> <Choice CommandStyle-Font-Bold="true" CommandStyle-Font-Name="Arial" /> </DeviceSpecific> <Command Name="Reserve" Text="Reserve" /> <Command Name="Buy" Text="Buy" /> </mobile:ObjectList> <mobile:Command ID="AllFieldsCmd" Runat="server" OnClick="AllFields_Click"> List All Fields</mobile:Command> <mobile:TextView ID="TextView2" Runat="server" /> </mobile:Form> <mobile:Form id="Form2" runat="server" BackColor="LightBlue"> <mobile:Label id="ResLabel" runat="server" text="Sale item reservation system coming soon!" /> <mobile:Link id="ResLink" NavigateURL="#Form1" runat="server" text="Return" /> </mobile:Form> <mobile:Form id="Form3" runat="server" BackColor="LightBlue"> <mobile:Label id="BuyLabel" runat="server" Text="Online purchasing system coming soon!" /> <mobile:Link ID="BuyLink" NavigateURL="#Form1" Runat="server" text="Return" /> </mobile:Form> <mobile:Form id="Form4" Runat="server" BackColor="LightBlue"> <mobile:Label ID="DefLabel" Runat="server" Text="Detailed item descriptions will be here soon!"/> <mobile:Link ID="DefLink" NavigateURL="#Form1" Runat="server" Text="Return" /> </mobile:Form> <mobile:Form ID="Form5" Runat="server"> <mobile:Label Runat="server"> List of AllFields:</mobile:Label> <mobile:TextView ID="TextView1" Runat="server" /> <mobile:Link Runat="server" NavigateUrl="#Form1" Text="Return"></mobile:Link> </mobile:Form> </body> </html>
これは、デバイス固有のいくつかのフィルタを持つサンプル Web.config ファイルです。
<configuration> <system.web> <compilation debug="true" /> <authentication mode="Windows" /> <customErrors mode="Off" /> <httpRuntime useFullyQualifiedRedirectUrl="true" /> <mobileControls cookielessDataDictionaryType="System.Web.Mobile.CookielessData" /> <deviceFilters> <!-- Only a few filters are provided here --> <filter name="isJPhone" compare="Type" argument="J-Phone" /> <filter name="isHTML32" compare="PreferredRenderingType" argument="html32" /> <filter name="isWML11" compare="PreferredRenderingType" argument="wml11" /> </deviceFilters> </system.web> </configuration>


System.Web.UI.Control
System.Web.UI.MobileControls.MobileControl
System.Web.UI.MobileControls.PagedControl
System.Web.UI.MobileControls.ObjectList


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


ObjectList コンストラクタ
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)


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


ObjectList プロパティ



ObjectList メソッド



名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackEventHandler.RaisePostBackEvent | このメンバの説明については、「IPostBackEventHandler.RaisePostBackEvent」を参照してください。 |

ObjectList メンバ
オブジェクト リスト内で項目ごとに複数のフィールドを指定して表示できるようにします。
ObjectList データ型で公開されるメンバを以下の表に示します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | ItemCommand | ObjectList 項目に関連付けられているコマンドをユーザーが選択すると発生します。 |
![]() | ItemDataBind | ObjectList 内の項目がデータにバインドされたときに発生します。 |
![]() | ItemSelect | ユーザーがリスト ビューから項目を選択した場合に発生します。 |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | LoadItems | コントロールの改ページ位置が自動修正され、さらにデータを必要とする場合に発生します。(PagedControl から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | ShowItemCommands | ObjectList 内の項目に関連付けられたコマンドが表示される前に発生します。 |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackEventHandler.RaisePostBackEvent | このメンバの説明については、「IPostBackEventHandler.RaisePostBackEvent」を参照してください。 |

- ObjectListのページへのリンク