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

削除されたレコードのキー以外のフィールドの名前と値のペアのディクショナリを格納している OrderedDictionary。

Values プロパティを使用して、削除されたレコードのキー以外のフィールドの値にアクセスします。たとえば、これらの値を使用して、削除されたレコードのログを維持できます。
![]() |
---|
Values プロパティは、項目テンプレートで双方向のバインド式が使用されている場合のみ設定されます。双方向のバインド式の詳細については、「データベースへのバインド」を参照してください。 |
Values プロパティは、System.Collections.Specialized.IOrderedDictionary インターフェイスを実装する OrderedDictionary オブジェクトを返します。OrderedDictionary オブジェクトは、削除されたレコードのキー以外のフィールドを表す System.Collections.DictionaryEntry オブジェクトを格納します。フィールド名にアクセスするには、OrderedDictionary オブジェクトの Keys プロパティを使用します。同様に、Values プロパティを使用して、フィールド値にアクセスできます。
![]() |
---|
OrderedDictionary オブジェクトのインデクサをショートカットとして使用しても、フィールド値にアクセスできます。インデクサを使用すると、直接インデクサからフィールド値が返されるというメリットがあります。フィールドの順序に依存するデータ ソース コントロール (AccessDataSource など) は、インデックスによってのみフィールド値にアクセスできます。 |
このプロパティには、(DataKeyNames プロパティで指定されている) 削除されたレコードのキー フィールドは格納されません。キー フィールドにアクセスするには、Keys プロパティを使用します。

Values プロパティを使用して、削除されたレコードのキー以外のフィールドの値にアクセスする方法の例を次に示します。
<%@ Page language="VB" %> <script runat="server"> Sub EmployeeFormView_ItemDeleted(ByVal sender As Object, ByVal e As FormViewDeletedEventArgs) Handles EmployeeFormView.ItemDeleted Dim entry As DictionaryEntry ' Display the values of the key fields in the Keys property. KeysMessageLabel.Text = _ "The key fields for the deleted record are: <br/>" ' In Visual Basic, you cannot iterate through the DictionaryEntry objects ' in the Keys property directly. Use the CopyTo method to ' copy the objects to an array first. Dim keysArray(e.Keys.Count - 1) As DictionaryEntry e.Keys.CopyTo(keysArray, 0) ' Iterate through the array and display its values. For Each entry In keysArray DisplayValue(entry, KeysMessageLabel) Next ' Display the values of the non-key fields in the Values ' property. ValuesMessageLabel.Text = _ "The non-key fields for the deleted record are: <br/>" Dim valuesArray(e.Values.Count - 1) As DictionaryEntry e.Values.CopyTo(valuesArray, 0) For Each entry In valuesArray DisplayValue(entry, ValuesMessageLabel) Next End Sub Sub DisplayValue(ByVal entry As DictionaryEntry, ByVal displayLabel As Label) ' Display the field name contained in the DictionaryEntry object. If entry.Key IsNot Nothing Then displayLabel.Text &= "Name=" & entry.Key.ToString() & ", " Else displayLabel.Text &= "Name=null, " End If ' Display the field value contained in the DictionaryEntry object. If entry.Value IsNot Nothing Then displayLabel.Text &= "Value=" & entry.Value.ToString() & "<br/>" Else displayLabel.Text &= "Value=null<br/>" End If End Sub </script> <html> <body> <form runat="server"> <h3>FormViewDeletedEventArgs Keys and Values Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" runat="server"> <itemtemplate> <table> <tr> <td> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td> <asp:label id="FirstNameLabel" text='<%#Bind("FirstName")%>' font-bold="true" runat="server"/> <asp:label id="LastNameLabel" text='<%#Bind("LastName")%>' font-bold="true" runat="server"/> <br/> <asp:label id="TitleLabel" text='<%#Bind("Title")%>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:button id="DeleteButton" text="Delete Record" commandname="Delete" runat="server" /> </td> </tr> </table> </itemtemplate> </asp:formview> <asp:label id="KeysMessageLabel" forecolor="Red" runat="server"/> <br/><br/> <asp:label id="ValuesMessageLabel" forecolor="Red" runat="server"/> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]" deletecommand="Delete [Employees] Where [EmployeeID]=@EmployeeID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void EmployeeFormView_ItemDeleted(Object sender, FormViewDeletedEventArgs e) { // Display the values of the key fields in the Keys property. KeysMessageLabel.Text = "The key fields for the deleted record are: <br/>"; foreach (DictionaryEntry entry in e.Keys) { DisplayValue(entry, KeysMessageLabel); } // Display the values of the non-key fields in the Values // property. ValuesMessageLabel.Text = "The non-key fields for the deleted record are: <br/>"; foreach (DictionaryEntry entry in e.Values) { DisplayValue(entry, ValuesMessageLabel); } } void DisplayValue(DictionaryEntry entry, Label displayLabel) { // Display the field name contained in the DictionaryEntry object. if (entry.Key != null) { displayLabel.Text += "Name=" + entry.Key.ToString() + ", "; } else { displayLabel.Text += "Name=null, "; } // Display the field value contained in the DictionaryEntry object. if (entry.Value != null) { displayLabel.Text += "Value=" + entry.Value.ToString() + "<br/>"; } else { displayLabel.Text += "Value=null<br/>"; } } </script> <html> <body> <form runat="server"> <h3>FormViewDeletedEventArgs Keys and Values Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" onitemdeleted="EmployeeFormView_ItemDeleted" runat="server"> <itemtemplate> <table> <tr> <td> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td> <asp:label id="FirstNameLabel" text='<%#Bind("FirstName")%>' font-bold="true" runat="server"/> <asp:label id="LastNameLabel" text='<%#Bind("LastName")%>' font-bold="true" runat="server"/> <br/> <asp:label id="TitleLabel" text='<%#Bind("Title")%>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:button id="DeleteButton" text="Delete Record" commandname="Delete" runat="server" /> </td> </tr> </table> </itemtemplate> </asp:formview> <asp:label id="KeysMessageLabel" forecolor="Red" runat="server"/> <br/><br/> <asp:label id="ValuesMessageLabel" forecolor="Red" runat="server"/> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]" deletecommand="Delete [Employees] Where [EmployeeID]=@EmployeeID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FormViewDeletedEventArgs クラス
FormViewDeletedEventArgs メンバ
System.Web.UI.WebControls 名前空間
FormView クラス
FormViewDeletedEventHandler
System.Collections.Specialized.IOrderedDictionary
System.Collections.Specialized.OrderedDictionary
System.Collections.DictionaryEntry
OrderedDictionary.Keys
OrderedDictionary.Values
FormViewDeletedEventArgs.Keys プロパティ
FormView.ItemDeleted イベント
Weblioに収録されているすべての辞書からFormViewDeletedEventArgs.Values プロパティを検索する場合は、下記のリンクをクリックしてください。

- FormViewDeletedEventArgs.Values プロパティのページへのリンク