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

挿入されたレコードのフィールドの名前と値のペアのディクショナリを格納している IOrderedDictionary オブジェクト。

Values プロパティを使用して、挿入されたレコードのフィールドの値にアクセスします。たとえば、これらの値を使用して、挿入されたレコードのログを維持できます。
Values プロパティは、System.Collections.Specialized.IOrderedDictionary インターフェイスを実装する OrderedDictionary オブジェクトを返します。OrderedDictionary オブジェクトは、挿入されたレコードのフィールドを表す System.Collections.DictionaryEntry オブジェクトを格納します。フィールド名にアクセスするには、OrderedDictionary オブジェクトの Keys プロパティを使用します。同様に、Values プロパティを使用して、フィールド値にアクセスできます。
![]() |
---|
ショートカットとして、OrderedDictionary オブジェクトのインデクサを使用してフィールド値に直接アクセスすることもできます。インデクサを使用すると、直接インデクサからフィールド値が返されるというメリットがあります。フィールドの順序に依存するデータ ソース コントロール (AccessDataSource など) は、インデックスによってのみフィールド値にアクセスできます。 |

Values コレクション内の項目を反復処理する方法を次の例に示します。
<%@ Page language="VB" %> <script runat="server"> Sub EmployeeFormView_ItemInserted(ByVal sender As Object, ByVal e As FormViewInsertedEventArgs) ' Iterate through the Values collection and display the ' values. MessageLabel.Text = "The Values collection contains " & _ "the following key/value pairs:<br/><br/>" ' In Visual Basic, the DictionaryItem objects contained in the ' Values collection must be copied to an array before ' you can iterate through the collection. Dim itemArray(e.Values.Count - 1) As DictionaryEntry e.Values.CopyTo(itemArray, 0) Dim entry As DictionaryEntry For Each entry In itemArray MessageLabel.Text &= "Key=" & entry.Key.ToString() & ", " & _ "Value=" & entry.Value.ToString() & "<br/>" Next End Sub </script> <html> <body> <form runat="server"> <h3>FormViewInsertedEventArgs Values Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." oniteminserted="EmployeeFormView_ItemInserted" runat="server"> <itemtemplate> <table> <tr> <td rowspan="5"> <asp:image id="CompanyLogoImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <%# Eval("FirstName") %> <%# Eval("LastName") %> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <%# Eval("Title") %> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="NewButton" text="New" commandname="New" runat="server"/> </td> </tr> </table> </itemtemplate> <insertitemtemplate> <table> <tr> <td rowspan="4"> <asp:image id="CompanyLogoEditImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameInsertTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameInsertTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleInsertTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="InsertButton" text="Insert" commandname="Insert" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </insertitemtemplate> </asp:formview> <br/><br/> <asp:label id="MessageLabel" 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]" insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void EmployeeFormView_ItemInserted(Object sender, FormViewInsertedEventArgs e) { // Iterate through the Values collection and display the // values. MessageLabel.Text = "The Values collection contains " + "the following key/value pairs:<br/><br/>"; foreach (DictionaryEntry entry in e.Values) { MessageLabel.Text += "Key=" + entry.Key.ToString() + ", " + "Value=" + entry.Value.ToString() + "<br/>"; } } </script> <html> <body> <form runat="server"> <h3>FormViewInsertedEventArgs Values Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." oniteminserted="EmployeeFormView_ItemInserted" runat="server"> <itemtemplate> <table> <tr> <td rowspan="5"> <asp:image id="CompanyLogoImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <%# Eval("FirstName") %> <%# Eval("LastName") %> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <%# Eval("Title") %> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="NewButton" text="New" commandname="New" runat="server"/> </td> </tr> </table> </itemtemplate> <insertitemtemplate> <table> <tr> <td rowspan="4"> <asp:image id="CompanyLogoEditImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameInsertTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameInsertTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleInsertTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="InsertButton" text="Insert" commandname="Insert" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </insertitemtemplate> </asp:formview> <br/><br/> <asp:label id="MessageLabel" 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]" insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)" 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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

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