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

Dim instance As GridView Dim value As Boolean value = instance.AutoGenerateDeleteButton instance.AutoGenerateDeleteButton = value
/** @property */ public boolean get_AutoGenerateDeleteButton () /** @property */ public void set_AutoGenerateDeleteButton (boolean value)
public function get AutoGenerateDeleteButton () : boolean public function set AutoGenerateDeleteButton (value : boolean)
データ行ごとに Delete ボタンを持つ CommandField フィールド列を自動的に追加する場合は true。それ以外の場合は false。既定値は false です。

削除機能をサポートしているデータ ソース コントロールが GridView コントロールにバインドされている場合、GridView コントロールは、データ ソース コントロールの機能を利用して、自動削除機能を提供します。
![]() |
---|
データを削除するデータ ソース コントロールの場合、データを削除するように構成する必要があります。レコードを削除するデータ ソース コントロールの構成については、該当するデータ ソース コントロールのドキュメントを参照してください。 |
AutoGenerateDeleteButton プロパティが true に設定されている場合、データ行ごとに Delete ボタンを持つ (CommandField オブジェクトで表される) 列が自動的に GridView コントロールに追加されます。行の Delete ボタンをクリックすると、そのレコードが完全にデータ ソースから削除されます。
GridView コントロールには、行が削除されるときにカスタム アクションを実行するために使用できる複数のイベントが用意されています。使用できるイベントの一覧を次の表に示します。

AutoGenerateDeleteButton プロパティを使用して、GridView コントロールの自動削除機能を有効にする方法を次のコード例に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>GridView Edit Example</h3> <!-- The GridView control automatically sets the columns --> <!-- specified in the datakeynames property as read-only. --> <!-- No input controls are rendered for these columns in --> <!-- edit mode. --> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="true" autogeneratedeletebutton="true" autogenerateeditbutton="true" datakeynames="CustomerID" runat="server"> </asp:gridview> <!-- 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="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" updatecommand="Update Customers SET CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country WHERE (CustomerID = @CustomerID)" deletecommand="Delete from Customers where CustomerID = @CustomerID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>GridView Edit Example</h3> <!-- The GridView control automatically sets the columns --> <!-- specified in the datakeynames property as read-only. --> <!-- No input controls are rendered for these columns in --> <!-- edit mode. --> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="true" autogeneratedeletebutton="true" autogenerateeditbutton="true" datakeynames="CustomerID" runat="server"> </asp:gridview> <!-- 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="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" updatecommand="Update Customers SET CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country WHERE (CustomerID = @CustomerID)" deletecommand="Delete from Customers where CustomerID = @CustomerID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からGridView.AutoGenerateDeleteButton プロパティを検索する場合は、下記のリンクをクリックしてください。

- GridView.AutoGenerateDeleteButton プロパティのページへのリンク