CommandField.ShowEditButton 속성

정의

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

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

속성 값

Boolean

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

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 ShowEditButton 의 각 레코드에 대 한 편집 단추에 표시할 속성을 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 showeditbutton="true"
            buttontype="Image"
            editimageurl="~\Images\EditButton.jpg"
            cancelimageurl="~\Images\CancelButton.jpg"
            updateimageurl="~\Images\UpdateButton.jpg"
            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]"
        updatecommand="Update Customers Set CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country 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 showeditbutton="true"
            buttontype="Image"
            editimageurl="~\Images\EditButton.jpg"
            cancelimageurl="~\Images\CancelButton.jpg"
            updateimageurl="~\Images\UpdateButton.jpg"
            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]"
        updatecommand="Update Customers Set CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID = @CustomerID)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

설명

사용 하 여 합니다 ShowEditButton 편집 단추에 표시 되는지 여부를 지정 하는 속성을 CommandField 데이터 소스 컨트롤에서 각 레코드에 대 한 필드입니다. 편집 단추를 사용 하는 레코드의 값을 편집할 수 있습니다.

사용자가 편집 단추를 클릭 하면 레코드의 각 필드에 대 한 입력된 컨트롤이 표시 됩니다. 업데이트 단추 및 취소 단추를 사용 하 여 레코드의 편집 단추가 대신 표시 되며 레코드에 대 한 다른 모든 명령 단추가 숨겨집니다. 작업을 취소 취소 단추를 클릭 하는 반면 데이터 원본에 새 값을 가진 레코드를 업데이트 [업데이트] 단추를 클릭 하 합니다.

참고

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

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

적용 대상

추가 정보