Aracılığıyla paylaş


CommandField.ShowEditButton Özellik

Tanım

Bir alanda Düzenle düğmesinin görüntülenip görüntülenmeyeceğini belirten bir CommandField değer alır veya ayarlar.

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

Özellik Değeri

trueiçinde düzenle düğmesini CommandFieldgörüntülemek için ; değilse. false Varsayılan değer: false.

Örnekler

Aşağıdaki kod örneği, bir denetimdeki ShowEditButton her kayıt GridView için düzenle düğmesini görüntülemek için özelliğinin nasıl kullanılacağını gösterir.


<%@ 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>

Açıklamalar

Veri kaynağı denetimindeki ShowEditButton her kayıt için alanda bir Düzenle düğmesinin görüntülenip görüntülenmeyeceğini CommandField belirtmek için özelliğini kullanın. Düzenle düğmesi, kaydın değerlerini düzenlemenizi sağlar.

Kullanıcı bir Düzenle düğmesine tıkladığında, kayıttaki her alan için giriş denetimleri görüntülenir. Kaydın Düzenle düğmesi bir Güncelleştir düğmesi ve İptal düğmesiyle değiştirilir ve kaydın diğer tüm komut düğmeleri gizlenir. Güncelleştir düğmesine tıklanması kaydı veri kaynağındaki yeni değerlerle güncelleştirirken İptal düğmesine tıklanması işlemi iptal eder.

Uyarı

Veriye bağlı denetim bir veri kaynağı denetimi (denetim gibi SqlDataSource ) ile birlikte kullanıldığında, veri bağlama denetimi veri kaynağı denetiminin özelliklerinden yararlanabilir ve otomatik güncelleştirme işlevselliği sağlayabilir. Diğer veri kaynakları için, veri bağlama denetimi için uygun olay sırasında güncelleştirme işlemini gerçekleştirmek için yordamları sağlamanız gerekir.

ButtonType Bir CommandField alanın özelliği veya ButtonType.Linkolarak ayarlandığındaButtonType.Button, düzenle düğmesi için görüntülenecek metni belirtmek üzere özelliğini kullanınEditText. Alternatif olarak, önce özelliğini olarak ve ardından özelliğini ButtonType.Image ayarlayarak ButtonTypeEditImageUrl bir görüntü görüntüleyebilirsiniz.

Şunlara uygulanır

Ayrıca bkz.