This article was translated by machine. To view in the article in English, select the English check box. You can also display the English text in a popup window by moving the mouse pointer over the text.
This documentation is archived and is not being maintained.

ButtonType قائمة تعداد

Visual Studio 2010

محاذاة عمودية هو ليست معينةها.

مساحة الاسم:  System.Web.UI.WebControls
التجميع:  System.Web (في System.Web.dll)

public enum ButtonType

اسم العضوالوصف
Buttonاستخدام خاصية لتحديد ما إذا كان المحتويات للخلية التفاف.
Imageإلى نوع عمود التحكم التي هو منضم إلى حقل في مصدر بيانات.
Link استخدم نوع العمود في عنصر تحكم لعرض محتويات حقل في مصدر بيانات.

المحتويات خلية تتم محاذاة مع الحافة العلوية للخلية.ButtonType It is commonly used by properties such as the ButtonType property of the ButtonFieldBase class to indicate which button type is being used by the parent control.

The following example demonstrates how to use the ButtonType enumeration to specify that link buttons are displayed in a ButtonField field column of a GridView control. The ButtonType property of a ButtonField object is declaratively set to ButtonType.Link.

<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">

  void AuthorsGridView_RowCommand(Object sender, GridViewCommandEventArgs e)

    // If multiple ButtonField column fields are used, use the
    // CommandName property to determine which button was clicked.

      // Convert the row index stored in the CommandArgument
      // property to an Integer.
      int index = Convert.ToInt32(e.CommandArgument);    

      // Get the last name of the selected author from the appropriate
      // cell in the GridView control.
      GridViewRow selectedRow = AuthorsGridView.Rows[index];
      TableCell lastNameCell = selectedRow.Cells[1];
      string lastName = lastNameCell.Text;  

      // Display the selected author.
      Message.Text = "You selected " + lastName + ".";



  void AuthorsGridView_RowCreated(Object sender, GridViewRowEventArgs e)

    // The GridViewCommandEventArgs class does not contain a 
    // property that indicates which row's command button was
    // clicked. To identify which row contains the button 
    // clicked, use the button's CommandArgument property by 
    // setting it to the row's index.
    if(e.Row.RowType == DataControlRowType.DataRow)

      // Retrieve the button control from the first column.
      // Because the ButtonType property of the column field
      // is set to ButtonType.Link, the button control must be
      // cast to a LinkButton. If you specify a different button
      // type, you must cast the button control to the appropriate
      // button type.
      LinkButton selectButton = (LinkButton)e.Row.Cells[0].Controls[0];

      // Set the LinkButton's CommandArgument property with the
      // row's index.
      selectButton.CommandArgument = e.Row.RowIndex.ToString();




<html xmlns="" >
  <head runat="server">
    <title>ButtonType Example</title>
    <form id="form1" runat="server">

      <h3>ButtonType Example</h3>

      <asp:label id="Message"

      <!-- Populate the Fields collection declaratively. -->
      <asp:gridview id="AuthorsGridView" 


          <asp:buttonfield buttontype="Link" commandname="Select" text="Select"/>
          <asp:boundfield datafield="au_lname" headertext="au_lname"/>
          <asp:boundfield datafield="au_fname" headertext="au_fname"/>



      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                        -->
      <asp:sqldatasource id="AuthorsSqlDataSource"  
        selectcommand="SELECT [au_lname], [au_fname] FROM [authors]"
        connectionstring="server=localhost;database=pubs;integrated security=SSPI"


نظام التشغيل Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, الإصدار x64 من نظام التشغيل Windows XP Professional, Windows XP Starter Edition, Windows Server 2008, نظام التشغيل Windows Server 2003, نظام التشغيل Windows Server 2000 المزود بحزمة الخدمة SP4, نظام التشغيل Windows Millennium Edition, نظام التشغيل Windows 98

لا يدعم .NET Framework و .NET Compact Framework كافة الإصدارات الخاصة بكل نظام أساسي. للحصول على قائمة بالإصدارات المدعمة، راجع متطلبات النظام إطار عمل .NET.

.NET Framework

مدعوم في: 4, 3.5, 3.0, 2.0