|
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
|
번역
원본
|
FormViewCommandEventArgs 클래스
System.EventArgs
System.Web.UI.WebControls.CommandEventArgs
System.Web.UI.WebControls.FormViewCommandEventArgs
네임스페이스: System.Web.UI.WebControls
어셈블리: System.Web(System.Web.dll)
FormViewCommandEventArgs 형식에서는 다음과 같은 멤버를 노출합니다.
| 이름 | 설명 | |
|---|---|---|
![]() | CommandArgument | |
![]() | CommandName | |
![]() | CommandSource | |
![]() | Handled |
| 이름 | 설명 | |
|---|---|---|
![]() | Equals(Object) | |
![]() | Finalize | 가비지 수집자 에서 회수하기 전에 개체에서 리소스를 해제하고 다른 정리 작업을 수행할 수 있게 합니다. |
![]() | GetHashCode | |
![]() | GetType | |
![]() | MemberwiseClone | |
![]() | ToString |
보안 정보 |
|---|
<%@ Page language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void ProductFormView_ItemCommand(Object sender, FormViewCommandEventArgs e) { // The ItemCommand event is raised when any button within // the FormView control is clicked. Use the CommandName property // to determine which button was clicked. if (e.CommandName == "Add") { // Add the product to the ListBox control. // Use the Row property to retrieve the data row. FormViewRow row = ProductFormView.Row; // Retrieve the ProductNameLabel control from // the data row. Label productNameLabel = (Label)row.FindControl("ProductNameLabel"); // Retrieve the QuantityTextBox control from // the data row. TextBox quantityTextBox = (TextBox)row.FindControl("QuantityTextBox"); if (productNameLabel != null && quantityTextBox != null) { // Get the product name from the ProductNameLabel control. string name = productNameLabel.Text; // Get the quantity from the QuantityTextBox control. string quantity = quantityTextBox.Text; // Create the text to display in the ListBox control. string description = name + " - " + quantity + " Qty"; // Create a ListItem object using the description and // product name. ListItem item = new ListItem(description, name); // Add the ListItem object to the ListBox. ProductListBox.Items.Add(item); // Use the CommandSource property to retrieve // the Add button. Disable the button after // the user adds the currently displayed employee // name to the ListBox control. Button addButton = (Button)e.CommandSource; addButton.Enabled = false; } } } void ProductFormView_DataBound(Object sender, EventArgs e) { // To prevent the user from adding duplicate items, // disable the Add button if the item being bound to the // FormView control is already in the ListBox control. // Use the Row property to retrieve the data row. FormViewRow row = ProductFormView.Row; // Retrieve the Add button from the data row. Button addButton = (Button)row.FindControl("AddButton"); // Retrieve the ProductNameLabel control from // data row. Label productNameLabel = (Label)row.FindControl("ProductNameLabel"); if (addButton != null && productNameLabel != null) { // Get the product name from the ProductNameLabel // control. string name = productNameLabel.Text; // Use the FindByValue method to determine whether // the ListBox control already contains an entry for // the item. ListItem item = ProductListBox.Items.FindByValue(name); // Disable the Add button if the ListBox control // already contains the item. if (item != null) { addButton.Enabled = false; } else { addButton.Enabled = true; } } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>FormViewCommandEventArgs Example</title> </head> <body> <form id="form1" runat="server"> <h3>FormViewCommandEventArgs Example</h3> <asp:formview id="ProductFormView" datasourceid="ProductSource" allowpaging="true" datakeynames="ProductID" onitemcommand="ProductFormView_ItemCommand" ondatabound="ProductFormView_DataBound" runat="server"> <itemtemplate> <table> <tr> <td style="width:400px"> <b>Description:</b> <asp:label id="ProductNameLabel" text='<%# Eval("ProductName") %>' runat='server'/> <br/> <b>Price:</b> <asp:label id="PriceLabel" text='<%# Eval("UnitPrice", "{0:c}") %>' runat='server'/> <br/> <asp:textbox id="QuantityTextBox" width="50px" maxlength="3" runat="server"/> Qty </td> </tr> <tr> <td> <asp:requiredfieldvalidator ID="QuantityRequiredValidator" controltovalidate="QuantityTextBox" text="Please enter a quantity." display="Static" runat="server"/> <br/> <asp:CompareValidator id="QuantityCompareValidator" controltovalidate="QuantityTextBox" text="Please enter an integer value." display="Static" type="Integer" operator="DataTypeCheck" runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:button id="AddButton" text="Add" commandname="Add" runat="server"/> </td> </tr> </table> </itemtemplate> </asp:formview> <br/><br/><hr/> Items:<br/> <asp:listbox id="ProductListBox" runat="server"/> <!-- 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="ProductSource" selectcommand="Select [ProductID], [ProductName], [UnitPrice] From [Products]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)
.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
