CommandField.ShowDeleteButton 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
삭제 단추가 필드에 표시되는 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
속성 값
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 컨트롤)과 함께 사용하는 경우 데이터 바인딩된 컨트롤은 데이터 원본 컨트롤의 기능을 활용하고 자동 삭제 기능을 제공할 수 있습니다. 다른 데이터 원본의 경우 데이터 바인딩된 컨트롤에 대한 적절한 이벤트 중에 삭제 작업을 수행하는 루틴을 제공해야 합니다.
필드의 ButtonTypeCommandField 속성을 설정 ButtonType.Button 하거나 ButtonType.Link삭제 단추에 표시할 텍스트를 지정하려면 이 속성을 사용합니다 DeleteText . 또는 먼저 속성을 설정한 다음 속성을 설정 ButtonTypeDeleteImageUrl 하여 이미지를 표시할 ButtonType.Image 수 있습니다.