CommandField.ShowDeleteButton 속성

정의

CommandField 필드에 삭제 단추를 표시할지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 virtual property bool ShowDeleteButton { bool get(); void set(bool value); };
public virtual bool ShowDeleteButton { get; set; }
member this.ShowDeleteButton : bool with get, set
Public Overridable Property ShowDeleteButton As Boolean

속성 값

Boolean

CommandField에 삭제 단추를 표시하려면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 ShowDeleteButton 속성의 각 레코드에 대 한 삭제 단추를 표시 하려면를 GridView 컨트롤입니다.


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>CommandField Example</title>
</head>
<body>
    <form id="form1" runat="server">
      
      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showdeletebutton="true"
            headertext="Edit Controls"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </columns>
        
      </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]"
        deletecommand="Delete [Customers] Where [CustomerID] = @CustomerID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>CommandField Example</title>
</head>
<body>
    <form id="form1" runat="server">
      
      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showdeletebutton="true"
            headertext="Edit Controls"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </columns>
        
      </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]"
        deletecommand="Delete [Customers] Where [CustomerID] = @CustomerID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

설명

사용 합니다 ShowDeleteButton 삭제 단추에 표시 되는지 여부를 지정 하는 속성을 CommandField 데이터 소스 컨트롤에서 각 레코드에 대 한 필드입니다. 삭제 단추를 사용 하면 데이터 원본에서 레코드를 제거 하려면 있습니다.

참고

데이터 바인딩된 컨트롤을 데이터 소스 컨트롤 함께 사용 하면 (같은 SqlDataSource 컨트롤)를 데이터 바인딩된 컨트롤을 데이터 소스 컨트롤의 기능을 사용할 수 있으며 자동 삭제 기능을 제공 합니다. 다른 데이터 원본의 경우 데이터 바인딩된 컨트롤에 대 한 적절 한 이벤트 중 삭제 작업을 수행 하는 루틴을 제공 해야 합니다.

경우는 ButtonType 의 속성을 CommandField 필드로 설정 됩니다 ButtonType.Button 또는 ButtonType.Link, 사용 하 여를 DeleteText 삭제 단추에 대해 표시할 텍스트를 지정 하는 속성. 또는 첫 번째 설정에 따라 이미지를 표시할 수는 ButtonType 속성을 ButtonType.Image 로 설정한는 DeleteImageUrl 속성입니다.

적용 대상

추가 정보