List.ItemDataBind イベント
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)

Dim instance As List Dim handler As ListDataBindEventHandler AddHandler instance.ItemDataBind, handler
public: event ListDataBindEventHandler^ ItemDataBind { void add (ListDataBindEventHandler^ value); void remove (ListDataBindEventHandler^ value); }

List 内の項目が作成されデータ バインドされると、このイベント ハンドラが、任意の式からそのリスト項目のプロパティを設定します。List 内の項目は、MobileListItem 型です。このイベントは、各データ ソース項目がバインドされたときに発生します。Text プロパティまたは Value プロパティを使用して MobileListItemCollection コレクション内の項目のフィルタ処理またはグループ化を行うには、このイベントの発生時が最も適切なタイミングです。

ItemDataBind イベントを使用して、リストのステータス設定の開始時の合計を取得する方法のコード例を次に示します。このコードは、List の概要で取り上げているコード例の一部分です。
Private Sub Status_DataBinding(ByVal sender As Object, _ ByVal e As ListDataBindEventArgs) ' Increment initial counts Select Case e.ListItem.Value Case "done" doneCount += 1 Case "scheduled" schedCount += 1 Case "pending" pendCount += 1 End Select End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Set the DataMembers of the List List1.DataValueField = "Status" List1.DataTextField = "TaskName" ' Create an ArrayList of task data Dim arr As ArrayList = New ArrayList() arr.Add(New Task("Define transactions", "scheduled")) arr.Add(New Task("Verify transactions", "scheduled")) arr.Add(New Task("Check balance sheet", "scheduled")) arr.Add(New Task("Compile balance sheet", "scheduled")) arr.Add(New Task("Prepare report", "scheduled")) arr.Add(New Task("Send report", "scheduled")) ' Bind the array to the list List1.DataSource = arr List1.DataBind() Const spec As String = "Start: {0} tasks are done, {1} " & _ "tasks are scheduled, and {2} tasks are pending." Label2.Text = String.Format(spec, doneCount, _ schedCount, pendCount) List1.Decoration = ListDecoration.Bulleted End If End Sub Private Sub Status_DataBinding(ByVal sender As Object, _ ByVal e As ListDataBindEventArgs) ' Increment initial counts Select Case e.ListItem.Value Case "done" doneCount += 1 Case "scheduled" schedCount += 1 Case "pending" pendCount += 1 End Select End Sub

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- List.ItemDataBind イベントのページへのリンク