CommandField.ShowDeleteButton Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bir alanda Sil düğmesinin görüntülenip görüntülenmeyeceğini belirten bir CommandField değer alır veya ayarlar.
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
Özellik Değeri
trueiçinde bir Delete düğmesi CommandFieldgörüntülemek için ; değilse. false Varsayılan değer: false.
Örnekler
Aşağıdaki kod örneği, bir denetimdeki ShowDeleteButton her kayıt GridView için delete 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 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>
Açıklamalar
Veri kaynağı denetimindeki ShowDeleteButton her kayıt için bir CommandField alanda Sil düğmesinin görüntülenip görüntülenmeyeceğini belirtmek için özelliğini kullanın. Sil düğmesi, bir kaydı veri kaynağından kaldırmanıza olanak tanır.
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 silme işlevi sağlayabilir. Diğer veri kaynakları için, veri bağlama denetimi için uygun olay sırasında silme 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, Sil düğmesi için görüntülenecek metni belirtmek üzere özelliğini kullanınDeleteText. Alternatif olarak, önce özelliğini olarak ve ardından özelliğini ButtonType.Image ayarlayarak ButtonTypeDeleteImageUrl bir görüntü görüntüleyebilirsiniz.