DetailsViewMode 列挙体
アセンブリ: System.Web (system.web.dll 内)

Public Enumeration DetailsViewMode

メンバ名 | 説明 | |
---|---|---|
Edit | 編集モード。ユーザーは既存のレコードの値を更新できます。 | |
Insert | 挿入モード。ユーザーは新しいレコードの値を入力できます。 | |
ReadOnly | 表示モード。ユーザーはレコードの値を変更できません。 |

DetailsViewMode 列挙体は、DetailsView コントロールのデータ入力モードを表すために使用されます。コントロールの現在のモードを確認するには、CurrentMode プロパティを使用します。挿入操作または更新操作の後で、DetailsView コントロールは DefaultMode プロパティで指定されたモードに戻ります。既定では、コントロールは読み取り専用モードに戻ります。DefaultMode プロパティを設定して、戻り先の代替モードを指定できます。プログラムによってモードを変更するには、ChangeMode メソッドを使用します。DetailsView コントロールがモードを変更すると、次の表に示すイベントが発生します。

DefaultMode プロパティを DetailsViewMode.Edit に設定し、更新操作後に DetailsView コントロールを編集モードのまま維持する方法のコード例を次に示します。
<%@ Page language="VB" %> <html> <body> <form id="Form1" runat="server"> <h3>DetailsView DefaultMode Example</h3> <asp:detailsview id="CustomerDetailView" datasourceid="DetailsViewSource" datakeynames="CustomerID" autogenerateeditbutton="true" autogeneraterows="true" allowpaging="true" defaultmode="Edit" runat="server"> <headerstyle backcolor="Navy" forecolor="White"/> </asp:detailsview> <!-- 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="DetailsViewSource" runat="server" ConnectionString= "<%$ ConnectionStrings:NorthWindConnectionString%>" InsertCommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)" SelectCommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"> </asp:SqlDataSource> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form id="Form1" runat="server"> <h3>DetailsView DefaultMode Example</h3> <asp:detailsview id="CustomerDetailView" datasourceid="DetailsViewSource" datakeynames="CustomerID" autogenerateeditbutton="true" autogeneraterows="true" allowpaging="true" defaultmode="Edit" runat="server"> <headerstyle backcolor="Navy" forecolor="White"/> </asp:detailsview> <!-- 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="DetailsViewSource" runat="server" ConnectionString= "<%$ ConnectionStrings:NorthWindConnectionString%>" InsertCommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)" SelectCommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"> </asp:SqlDataSource> </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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DetailsViewMode 列挙体のページへのリンク