ListView 類別

定義

以使用者定義的範本來顯示資料來源值。 ListView 控制項可讓使用者選取、排序、刪除、編輯和插入記錄。

public ref class ListView : System::Web::UI::WebControls::DataBoundControl, System::Web::UI::INamingContainer, System::Web::UI::WebControls::IPageableItemContainer, System::Web::UI::WebControls::IPersistedSelector
public ref class ListView : System::Web::UI::WebControls::DataBoundControl, System::Web::UI::IDataKeysControl, System::Web::UI::INamingContainer, System::Web::UI::WebControls::IDataBoundListControl, System::Web::UI::WebControls::IPageableItemContainer, System::Web::UI::WebControls::IPersistedSelector
[System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.ListView), "ListView.ico")]
[System.Web.UI.ControlValueProperty("SelectedValue")]
public class ListView : System.Web.UI.WebControls.DataBoundControl, System.Web.UI.INamingContainer, System.Web.UI.WebControls.IPageableItemContainer, System.Web.UI.WebControls.IPersistedSelector
[System.Web.UI.ControlValueProperty("SelectedValue")]
[System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.ListView), "ListView.bmp")]
public class ListView : System.Web.UI.WebControls.DataBoundControl, System.Web.UI.IDataKeysControl, System.Web.UI.INamingContainer, System.Web.UI.WebControls.IDataBoundListControl, System.Web.UI.WebControls.IPageableItemContainer, System.Web.UI.WebControls.IPersistedSelector
[<System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.ListView), "ListView.ico")>]
[<System.Web.UI.ControlValueProperty("SelectedValue")>]
type ListView = class
    inherit DataBoundControl
    interface INamingContainer
    interface IPageableItemContainer
    interface IPersistedSelector
[<System.Web.UI.ControlValueProperty("SelectedValue")>]
[<System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.ListView), "ListView.bmp")>]
type ListView = class
    inherit DataBoundControl
    interface INamingContainer
    interface IPageableItemContainer
    interface IPersistedSelector
    interface IDataKeysControl
    interface IDataBoundListControl
    interface IDataBoundControl
Public Class ListView
Inherits DataBoundControl
Implements INamingContainer, IPageableItemContainer, IPersistedSelector
Public Class ListView
Inherits DataBoundControl
Implements IDataBoundListControl, IDataKeysControl, INamingContainer, IPageableItemContainer, IPersistedSelector
繼承
屬性
實作

範例

下列範例示範如何使用 ListView 控制項,使用 HTML 資料表顯示資料庫中的記錄。 這些值是使用 LinqDataSource 控制項來擷取。

<%@ 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 id="Head1" runat="server">
    <title>ListView Example</title>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>ListView Example</h3>
                       
      <asp:ListView ID="VendorsListView"
        DataSourceID="VendorsDataSource"
        DataKeyNames="VendorID"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" border="1" ID="tbl1" runat="server">
            <tr runat="server" style="background-color: #98FB98">
              <th runat="server">ID</th>
              <th runat="server">Account Number</th>
              <th runat="server">Name</th>
              <th runat="server">Preferred Vendor</th>
            </tr>
            <tr runat="server" id="itemPlaceholder" />
          </table>
          <asp:DataPager ID="DataPager1" runat="server">
            <Fields>
              <asp:NumericPagerField />
            </Fields>
          </asp:DataPager>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="VendorIDLabel" runat="server" Text='<%# Eval("VendorID") %>' />
            </td>
            <td>
              <asp:Label ID="AccountNumberLabel" runat="server" Text='<%# Eval("AccountNumber") %>' />
            </td>
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /></td>
            <td>
              <asp:CheckBox ID="PreferredCheckBox" runat="server" 
                Checked='<%# Eval("PreferredVendorStatus") %>' Enabled="False" />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <!-- This example uses Microsoft SQL Server and connects   -->
      <!-- to the AdventureWorks sample database. Add a LINQ     -->
      <!-- to SQL class to the project to map to a table in      -->
      <!-- the database.                                         -->
      <asp:LinqDataSource ID="VendorsDataSource" runat="server" 
        ContextTypeName="AdventureWorksClassesDataContext" 
        Select="new (VendorID, AccountNumber, Name, PreferredVendorStatus)" 
        TableName="Vendors" Where="ActiveFlag == @ActiveFlag">
        <WhereParameters>
          <asp:Parameter DefaultValue="true" Name="ActiveFlag" Type="Boolean" />
        </WhereParameters>
      </asp:LinqDataSource>
      
    </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 id="Head1" runat="server">
    <title>ListView Example</title>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>ListView Example</h3>
                       
      <asp:ListView ID="VendorsListView"
        DataSourceID="VendorsDataSource"
        DataKeyNames="VendorID"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" border="1" ID="tbl1" runat="server">
            <tr runat="server" style="background-color: #98FB98">
              <th runat="server">ID</th>
              <th runat="server">Account Number</th>
              <th runat="server">Name</th>
              <th runat="server">Preferred Vendor</th>
            </tr>
            <tr runat="server" id="itemPlaceholder" />
          </table>
          <asp:DataPager ID="DataPager1" runat="server">
            <Fields>
              <asp:NumericPagerField />
            </Fields>
          </asp:DataPager>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="VendorIDLabel" runat="server" Text='<%# Eval("VendorID") %>' />
            </td>
            <td>
              <asp:Label ID="AccountNumberLabel" runat="server" Text='<%# Eval("AccountNumber") %>' />
            </td>
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /></td>
            <td>
              <asp:CheckBox ID="PreferredCheckBox" runat="server" 
                Checked='<%# Eval("PreferredVendorStatus") %>' Enabled="False" />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <!-- This example uses Microsoft SQL Server and connects   -->
      <!-- to the AdventureWorks sample database. Add a LINQ     -->
      <!-- to SQL class to the project to map to a table in      -->
      <!-- the database.                                         -->
      <asp:LinqDataSource ID="VendorsDataSource" runat="server" 
        ContextTypeName="AdventureWorksClassesDataContext" 
        Select="new (VendorID, AccountNumber, Name, PreferredVendorStatus)" 
        TableName="Vendors" Where="ActiveFlag == @ActiveFlag">
        <WhereParameters>
          <asp:Parameter DefaultValue="true" Name="ActiveFlag" Type="Boolean" />
        </WhereParameters>
      </asp:LinqDataSource>
      
    </form>
  </body>
</html>

下列範例示範如何使用 控制項,使用 ListView 元素在流程配置 div 中顯示值。 這些值是使用 SqlDataSource 控制項來擷取。

<%@ 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 id="Head1" runat="server">
    <title>ListView Flow Layout Example</title>
    <style type="text/css">
      .plainBox {
          font-family: Verdana, Arial, sans-serif;
          font-size: 11px;
          background: #ffffff;
          border:1px solid #336666;
          }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">

      <h3>ListView Flow Layout Example</h3>
      
      Select the color:
      <asp:DropDownList ID="ColorList" runat="server" 
        AutoPostBack="True" 
        DataSourceID="ColorDataSource" 
        DataTextField="Color" 
        DataValueField="Color">
      </asp:DropDownList><br /><br />
      
      <asp:ListView runat="server" ID="ProductListView"
        DataSourceID="ProductsDataSource"
        DataKeyNames="ProductID">
        <LayoutTemplate>
          <div runat="server" id="lstProducts">
            <div runat="server" id="itemPlaceholder" />
          </div>
          <asp:DataPager runat="server" PageSize="5" >
            <Fields>
              <asp:NextPreviousPagerField 
                ButtonType="Button"
                ShowFirstPageButton="True" 
                ShowLastPageButton="True" />
            </Fields>
          </asp:DataPager>
        </LayoutTemplate>
        <ItemTemplate>
          <asp:Image ID="ProductImage" runat="server"
            ImageUrl='<%# "~/images/thumbnails/" + Eval("ThumbnailPhotoFileName") %>' />	        
          <div class="plainBox" runat="server">
            <asp:HyperLink ID="ProductLink" runat="server" Text='<%# Eval("Name") %>' 
              NavigateUrl='<%# "ProductDetails.aspx?productID=" + Eval("ProductID") %>' />
            <br /><br />
            <b>Price:</b> 
            <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("ListPrice", "{0:c}")%>' /> <br />
          </div>
          <br />
        </ItemTemplate>
      </asp:ListView>
      
      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->
      <asp:SqlDataSource ID="ProductsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"            	        
        SelectCommand="SELECT P.ProductID, P.Name, P.Color, P.ListPrice, 
          PF.ThumbnailPhotoFileName, P.Size
          FROM Production.Product AS P 
          INNER JOIN Production.ProductProductPhoto AS PPF ON P.ProductID = PPF.ProductID 
          INNER JOIN Production.ProductPhoto AS PF ON PPF.ProductPhotoID = PF.ProductPhotoID
          WHERE P.Color = @Color" >
        <SelectParameters>
          <asp:ControlParameter ControlID="ColorList" Name="Color" 
            PropertyName="SelectedValue" />
        </SelectParameters>
      </asp:SqlDataSource>

      <asp:SqlDataSource ID="ColorDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>" 
        SelectCommand="SELECT DISTINCT Color FROM Production.Product">
      </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 id="Head1" runat="server">
    <title>ListView Flow Layout Example</title>
    <style type="text/css">
      .plainBox {
          font-family: Verdana, Arial, sans-serif;
          font-size: 11px;
          background: #ffffff;
          border:1px solid #336666;
          }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">

      <h3>ListView Flow Layout Example</h3>
      
      Select the color:
      <asp:DropDownList ID="ColorList" runat="server" 
        AutoPostBack="True" 
        DataSourceID="ColorDataSource" 
        DataTextField="Color" 
        DataValueField="Color">
      </asp:DropDownList><br /><br />
      
      <asp:ListView runat="server" ID="ProductListView"
        DataSourceID="ProductsDataSource"
        DataKeyNames="ProductID">
        <LayoutTemplate>
          <div runat="server" id="lstProducts">
            <div runat="server" id="itemPlaceholder" />
          </div>
          <asp:DataPager ID="DataPager1" runat="server" PageSize="5" >
            <Fields>
              <asp:NextPreviousPagerField 
                ButtonType="Button"
                ShowFirstPageButton="True" 
                ShowLastPageButton="True" />
            </Fields>
          </asp:DataPager>
        </LayoutTemplate>
        <ItemTemplate>
          <asp:Image ID="ProductImage" runat="server"
            ImageUrl='<%# "~/images/thumbnails/" & Eval("ThumbnailPhotoFileName") %>' />	        
          <div class="plainBox" runat="server">
            <asp:HyperLink ID="ProductLink" runat="server" Text='<%# Eval("Name") %>' 
              NavigateUrl='<%# "ProductDetails.aspx?productID=" & Eval("ProductID") %>' />
            <br /><br />
            <b>Price:</b> 
            <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("ListPrice", "{0:c}")%>' /> <br />
          </div>
          <br />
        </ItemTemplate>
      </asp:ListView>
      
      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->
      <asp:SqlDataSource ID="ProductsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"            	        
        SelectCommand="SELECT P.ProductID, P.Name, P.Color, P.ListPrice, 
          PF.ThumbnailPhotoFileName, P.Size
          FROM Production.Product AS P 
          INNER JOIN Production.ProductProductPhoto AS PPF ON P.ProductID = PPF.ProductID 
          INNER JOIN Production.ProductPhoto AS PF ON PPF.ProductPhotoID = PF.ProductPhotoID
          WHERE P.Color = @Color" >
        <SelectParameters>
          <asp:ControlParameter ControlID="ColorList" Name="Color" 
            PropertyName="SelectedValue" />
        </SelectParameters>
      </asp:SqlDataSource>

      <asp:SqlDataSource ID="ColorDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>" 
        SelectCommand="SELECT DISTINCT Color FROM Production.Product">
      </asp:SqlDataSource>

    </form>
  </body>
</html>

下列範例示範如何使用 ListView 控制項來插入、刪除和更新記錄。

重要

這個範例有一個可接受使用者輸入的文字方塊,這可能會造成安全性威脅。 根據預設,ASP.NET Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。

<%@ 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 id="Head1" runat="server">
    <title>ListView Example</title>
    <style type="text/css">
        .EditItem { background-color:#8FBC8F;}
        .SelectedItem {	background-color:#9ACD32; }
        .InsertItem { background-color:#FFFACD;}
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>ListView Example</h3>
      
      <h5>Departments</h5>

      <asp:ListView ID="DepartmentsListView" 
        DataSourceID="DepartmentsDataSource" 
        DataKeyNames="DepartmentID"
        ConvertEmptyStringToNull="true"
        InsertItemPosition="LastItem"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" runat="server" id="tblDepartments" width="640px" cellspacing="0">
            <tr runat="server" id="itemPlaceholder" />
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Button ID="SelectButton" runat="server" Text="Select" CommandName="Select" />
              <asp:Button ID="EditButton" runat="server" Text="Edit" CommandName="Edit" />
            </td>
            <td>
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("DepartmentID") %>' />
            </td>
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
            </td>
            <td>
              <asp:Label ID="GroupNameLabel" runat="server" Text='<%#Eval("GroupName") %>' />
            </td>
          </tr>
        </ItemTemplate>
        <SelectedItemTemplate>
          <tr class="SelectedItem" runat="server">
            <td>
              <asp:Button ID="DeleteButton" runat="server" Text="Delete" CommandName="Delete" />
              <asp:Button ID="EditButton" runat="server" Text="Edit" CommandName="Edit" />
            </td>
            <td>
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("DepartmentID") %>' />
            </td>
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
            </td>
            <td>
              <asp:Label ID="GroupNameLabel" runat="server" Text='<%#Eval("GroupName") %>' />
            </td>
          </tr>
        </SelectedItemTemplate>
        <EditItemTemplate>
          <tr class="EditItem">
            <td>
              <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
              <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
            </td>
            <td>
              <b>ID</b><br />
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("DepartmentID") %>' />
            </td>
            <td>
              <asp:Label runat="server" ID="NameLabel" AssociatedControlID="NameTextBox" 
                Text="Name" Font-Bold="true"/><br />
              <asp:TextBox ID="NameTextBox" runat="server" Text='<%#Bind("Name") %>' />
            </td>
            <td>
              <asp:Label runat="server" ID="GroupNameLabel" AssociatedControlID="GroupNameTextBox" 
                Text="Group Name" Font-Bold="true" /><br />
              <asp:TextBox ID="GroupNameTextBox" runat="server" 
                Width="200px"
                Text='<%#Bind("GroupName") %>' />
              <br />
            </td>
          </tr>
        </EditItemTemplate>
        <InsertItemTemplate>
          <tr class="InsertItem">
            <td colspan="2">
              <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
              <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
            </td>
            <td>
              <asp:Label runat="server" ID="NameLabel" AssociatedControlID="NameTextBox" 
                Text="Name" Font-Bold="true"/><br />
              <asp:TextBox ID="NameTextBox" runat="server" Text='<%#Bind("Name") %>' /><br />
            </td>
            <td>
              <asp:Label runat="server" ID="GroupNameLabel" AssociatedControlID="GroupNameTextBox" 
                Text="Group Name" Font-Bold="true" /><br />                
              <asp:TextBox ID="GroupNameTextBox" runat="server" Text='<%#Bind("GroupName") %>' />
            </td>
          </tr>
        </InsertItemTemplate>
      </asp:ListView>

      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->            
      <asp:SqlDataSource ID="DepartmentsDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
            SelectCommand="SELECT DepartmentID, Name, GroupName FROM HumanResources.Department"
            UpdateCommand="UPDATE HumanResources.Department 
                SET Name = @Name, GroupName = @GroupName WHERE (DepartmentID = @DepartmentID)"            
            DeleteCommand="DELETE FROM HumanResources.Department 
                WHERE (DepartmentID = @DepartmentID)" 
            InsertCommand="INSERT INTO HumanResources.Department(Name, GroupName) 
                VALUES (@Name, @GroupName)">
      </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 id="Head1" runat="server">
    <title>ListView Example</title>
    <style type="text/css">
        .EditItem { background-color:#8FBC8F;}
        .SelectedItem {	background-color:#9ACD32; }
        .InsertItem { background-color:#FFFACD;}
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>ListView Example</h3>
      
      <h5>Departments</h5>

      <asp:ListView ID="DepartmentsListView" 
        DataSourceID="DepartmentsDataSource" 
        DataKeyNames="DepartmentID"
        ConvertEmptyStringToNull="true"
        InsertItemPosition="LastItem"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" runat="server" id="tblDepartments" width="640px" cellspacing="0">
            <tr runat="server" id="itemPlaceholder" />
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Button ID="SelectButton" runat="server" Text="Select" CommandName="Select" />
              <asp:Button ID="EditButton" runat="server" Text="Edit" CommandName="Edit" />
            </td>
            <td>
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("DepartmentID") %>' />
            </td>
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
            </td>
            <td>
              <asp:Label ID="GroupNameLabel" runat="server" Text='<%#Eval("GroupName") %>' />
            </td>
          </tr>
        </ItemTemplate>
        <SelectedItemTemplate>
          <tr class="SelectedItem" runat="server">
            <td>
              <asp:Button ID="DeleteButton" runat="server" Text="Delete" CommandName="Delete" />
              <asp:Button ID="EditButton" runat="server" Text="Edit" CommandName="Edit" />
            </td>
            <td>
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("DepartmentID") %>' />
            </td>
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
            </td>
            <td>
              <asp:Label ID="GroupNameLabel" runat="server" Text='<%#Eval("GroupName") %>' />
            </td>
          </tr>
        </SelectedItemTemplate>
        <EditItemTemplate>
          <tr class="EditItem">
            <td>
              <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
              <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
            </td>
            <td>
              <b>ID</b><br />
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("DepartmentID") %>' />
            </td>
            <td>
              <asp:Label runat="server" ID="NameLabel" AssociatedControlID="NameTextBox" 
                Text="Name" Font-Bold="true"/><br />
              <asp:TextBox ID="NameTextBox" runat="server" Text='<%#Bind("Name") %>' />
            </td>
            <td>
              <asp:Label runat="server" ID="GroupNameLabel" AssociatedControlID="GroupNameTextBox" 
                Text="Group Name" Font-Bold="true" /><br />
              <asp:TextBox ID="GroupNameTextBox" runat="server" 
                Width="200px"
                Text='<%#Bind("GroupName") %>' />
              <br />
            </td>
          </tr>
        </EditItemTemplate>
        <InsertItemTemplate>
          <tr class="InsertItem">
            <td colspan="2">
              <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
              <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
            </td>
            <td>
              <asp:Label runat="server" ID="NameLabel" AssociatedControlID="NameTextBox" 
                Text="Name" Font-Bold="true"/><br />
              <asp:TextBox ID="NameTextBox" runat="server" Text='<%#Bind("Name") %>' /><br />
            </td>
            <td>
              <asp:Label runat="server" ID="GroupNameLabel" AssociatedControlID="GroupNameTextBox" 
                Text="Group Name" Font-Bold="true" /><br />                
              <asp:TextBox ID="GroupNameTextBox" runat="server" Text='<%#Bind("GroupName") %>' />
            </td>
          </tr>
        </InsertItemTemplate>
      </asp:ListView>

      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->            
      <asp:SqlDataSource ID="DepartmentsDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
            SelectCommand="SELECT DepartmentID, Name, GroupName FROM HumanResources.Department"
            UpdateCommand="UPDATE HumanResources.Department 
                SET Name = @Name, GroupName = @GroupName WHERE (DepartmentID = @DepartmentID)"            
            DeleteCommand="DELETE FROM HumanResources.Department 
                WHERE (DepartmentID = @DepartmentID)" 
            InsertCommand="INSERT INTO HumanResources.Department(Name, GroupName) 
                VALUES (@Name, @GroupName)">
      </asp:SqlDataSource>
      
    </form>
  </body>
</html>

備註

本主題內容:

簡介

控制項 ListView 可用來顯示資料來源中的值。 它類似于 GridView 控制項,不同之處在于它會使用使用者定義的範本來顯示資料,而不是資料欄欄位。 建立您自己的範本可讓您更有彈性地控制資料的顯示方式。

具有原始程式碼的 Visual Studio 專案隨附于本主題: 下載

控制項 ListView 支援下列功能:

  • 支援系結至資料來源控制項,例如 SqlDataSourceLinqDataSourceObjectDataSource

  • 可透過使用者定義的範本和樣式自訂外觀。

  • 內建排序功能。

  • 內建更新和刪除功能。

  • 內建插入功能。

  • 支援使用 DataPager 控制項的分頁功能。

  • 內建專案選取功能。

  • 以程式設計方式存取 ListView 物件模型,以動態設定屬性、處理事件等等。

  • 多個索引鍵欄位。

若要瞭解 ASP.NET 中可用的其他資料繫結控制項,請參閱 資料系結 Web 服務器控制項

範本

若要讓 ListView 控制項顯示內容,您必須為控制項的不同部分建立範本。 ItemTemplate 是必要項目。 所有其他範本都是選擇性的。 不需要 屬性 LayoutTemplate

不過,您必須為設定控制項的模式建立範本。 例如, ListView 支援插入記錄的控制項必須已 InsertItemTemplate 定義範本。 下表列出您可以為控制項建立的 ListView 範本。

範本類型 描述
LayoutTemplate 定義容器物件的根範本,例如 tabledivspan 元素,將包含 或 GroupTemplate 範本中 ItemTemplate 定義的內容。 它也可能包含 DataPager 物件。
ItemTemplate 定義要針對個別專案顯示的資料系結內容。
ItemSeparatorTemplate 定義在個別專案之間呈現的內容。
GroupTemplate 定義容器物件,例如資料表資料列 () trdivspan 元素,其中包含 和 EmptyItemTemplate 範本中 ItemTemplate 定義的內容。 屬性會 GroupItemCount 指定群組中顯示的專案數。
GroupSeparatorTemplate 定義在專案群組之間呈現的內容。
EmptyItemTemplate 定義使用範本時 GroupTemplate 要呈現空白專案的內容。 例如,如果 GroupItemCount 屬性設定為 5,而從資料來源傳回的專案總數為 8,控制項所顯示 ListView 的最後一組資料將會包含範本所 ItemTemplate 指定的三個專案,以及範本所 EmptyItemTemplate 指定的兩個專案。
EmptyDataTemplate 定義資料來源沒有傳回任何資料時要呈現的內容。
SelectedItemTemplate 定義要呈現所選資料項目的內容,以區分選取的專案與其他專案。
AlternatingItemTemplate 定義要轉譯給替代專案的內容,以便更輕鬆地區分連續的專案。
EditItemTemplate 定義編輯專案時要呈現的內容。 範本 EditItemTemplate 會轉譯為 ItemTemplate 正在編輯之資料項目的範本。
InsertItemTemplate 定義要呈現以插入專案的內容。 範本 InsertItemTemplate 會轉譯為 ItemTemplate 在控制項所顯示 ListView 專案的開頭或結尾取代範本。 您可以使用 控制項的 ListView 屬性來指定範本 InsertItemPosition 轉譯的位置 InsertItemTemplate

若要在範本中顯示欄位的值,請使用 ItemTemplate 資料系結運算式。 如需資料系結運算式的詳細資訊,請參閱 資料系結運算式概觀

若要將 EditItemTemplateInsertItemTemplate 範本中的輸入控制項系結至資料來源的欄位,您可以使用雙向系結運算式。 這可讓 ListView 控制項自動擷取更新或插入作業之輸入控制項的值。 雙向系結運算式也會讓 中的 EditItemTemplate 輸入控制項自動顯示原始域值。 如需雙向系結運算式的詳細資訊,請參閱 系結至資料庫

系結至資料來源

您可以將控制項系結 ListView 至資料來源控制項 (例如 SqlDataSource 控制項或 ObjectDataSource 控制項) ,或實作 System.Collections.IEnumerable 介面的任何資料來源集合,例如 System.Data.DataViewSystem.Collections.ArrayListSystem.Collections.Generic.List<T> 或其他集合類型。 使用下列其中一種方法,將 ListView 控制項系結至適當的資料來源類型:

  • 若要系結至資料來源控制項,請將 DataSourceID 控制項的 ListView 屬性設定為 ID 資料來源控制項的值。 控制項 ListView 會自動系結至指定的資料來源控制項,並可以利用資料來源控制項的功能來執行排序、插入、更新、刪除和分頁功能。 這是系結至資料的慣用方法。

  • 若要系結至實作 System.Collections.IEnumerable 介面的資料來源,請以程式設計方式將 控制項的 ListView 屬性設定 DataSource 為數據源,然後呼叫 DataBind 方法。 當您使用這項技術時, ListView 控制項不會提供內建排序、更新、刪除和分頁功能。 您必須使用適當的事件來提供這項功能。

如需資料系結的詳細資訊,請參閱 ASP.NET 資料存取內容對應

注意

控制項 ListView 可用來顯示使用者輸入,其中可能包含惡意用戶端腳本。 在應用程式中顯示可執行檔腳本、SQL 語句或其他程式碼之前,請先檢查從用戶端傳送的任何資訊。 強烈建議值盡可能以 HTML 編碼,再顯示于此控制項中。 ASP.NET 提供輸入要求驗證功能,以協助封鎖使用者輸入中的腳本和 HTML。 您也可以使用驗證服務器控制項來檢查使用者輸入。 如需詳細資訊,請參閱 驗證控制項簡介

資料作業

ListView當控制項系結至資料來源控制項時, ListView 控制項可以利用資料來源控制項的功能,並提供自動排序、插入、更新和刪除功能。

注意

控制項 ListView 可以支援使用其他類型的資料來源排序、插入、更新和刪除。 不過,若要實作這些作業,您必須在適當的事件處理常式中建立程式碼。

ListView因為控制項使用範本,所以它不提供自動產生按鈕來執行更新、刪除、插入、排序或選取作業的方法。 您必須在適當的範本中手動包含這些按鈕。 控制項 ListView 會辨識屬性設定為特定值的特定按鈕 CommandName 。 下表列出控制項可辨識的按鈕 ListView 及其函式。

按鈕 CommandName 值 描述
取消 「Cancel」 取消編輯或插入作業。 引發 ItemCanceling 事件。
刪除 "Delete" 將目前的資料錄從資料來源中刪除。 ItemDeleted引發 和 ItemDeleting 事件。
選取 "Select" SelectedIndex 屬性設定為 DisplayIndex 專案的屬性值。 呈現 SelectedItemTemplate 專案的範本。 SelectedIndexChanging引發 和 SelectedIndexChanged 事件。
編輯 「Edit」 將專案置於編輯模式中。 呈現 EditItemTemplate 專案的範本。 引發 ItemEditing 事件。
插入 「Insert」 將範本中的 InsertItemTemplate 系結值插入資料來源。 ItemInserting引發 和 ItemInserted 事件。
更新 「Update」 更新資料來源中具有樣板系結值的 EditItemTemplate 目前記錄。 ItemUpdating引發 和 ItemUpdated 事件。
Sort 「Sort」 排序按鈕的 屬性中列出的 CommandArgument 資料行。 Sorting引發 和 Sorted 事件。

不同于 [刪除] 按鈕 (會立即刪除目前資料項目) ,按一下 [編輯] 按鈕時, ListView 控制項會以編輯模式顯示目前的專案。 在編輯模式中,會針對目前資料項目顯示內容中包含的 EditItemTemplate 內容。 一般而言,在編輯專案範本中,[編輯] 按鈕會取代為 [更新] 和 [取消] 按鈕。 適用于欄位資料類型的輸入控制項 (,例如 TextBoxCheckBox 控制項) 通常也會向使用者顯示要修改的域值。 按一下 [更新] 按鈕會更新資料來源中的記錄,然後按一下 [取消] 按鈕會取消編輯作業。

當 屬性設定為 FirstItemLastItemInsertItemPosition ,就會啟用插入功能。 這個屬性會定義為插入專案轉譯範本的位置 InsertItemTemplate 。 插入專案範本通常包含 [插入] 和 [取消] 按鈕,並顯示空白輸入控制項,讓使用者輸入新記錄的值。 按一下 [插入] 按鈕會在資料來源中插入記錄,然後按一下 [取消] 按鈕會清除所有欄位。

排序

控制項 ListView 可讓使用者按一下 [排序] 按鈕來排序專案。 排序功能定義于按鈕的 屬性中 CommandArgument ,其中包含要排序的資料行。

Paging

控制項不會同時顯示資料來源中的所有記錄, ListView 而是可以將記錄分成數頁。 若要啟用分頁,請將 DataPager 控制項與 ListView 控制項產生關聯。 然後在範本內 LayoutTemplate 插入 DataPager 控制項。 或者,如果 DataPager 控制項不在 控制項之外 ListView ,請將 PagedControlID 屬性設定為 ID 控制項的 ListView

事件

下表列出 控制項所支援 ListView 的事件。

事件 描述
ItemCanceling 發生于按一下 [取消] 按鈕 (設定為 CommandName 「Cancel」) 的按鈕時,但在控制項取消插入或編輯作業之前 ListView 。 此事件通常用於停止取消作業。
ItemCommand 按一下 ListView 控制項中的按鈕時會發生這個事件。 這個事件通常用於在控制項中按一下按鈕時執行自訂工作。
ItemCreated 在 控制項中 ListView 建立新專案時發生。 建立專案時,通常會使用此事件來修改專案的內容。
ItemDataBound 發生于資料項目系結至 控制項中的資料 ListView 時。 當專案系結至資料時,通常會使用此事件來修改專案的內容。
ItemDeleted 發生于控制項從資料來源刪除記錄之後,將 [刪除] 按鈕 (其 CommandName 屬性設定為 「Delete」) 或 DeleteItem 呼叫 方法時 ListView 。 此事件通常用於檢查刪除作業的結果。
ItemDeleting 發生于按一下 [刪除] 按鈕 (設定為 CommandName 「Delete」 ) 的按鈕時,或 DeleteItem 呼叫 方法,但在控制項從資料來源刪除記錄之前 ListView 。 此事件通常用於確認或取消刪除作業。
ItemEditing 發生于按一下 [編輯] 按鈕 (按鈕,且其 CommandName 屬性設定為 [編輯] ) ,但在控制項進入編輯模式之前 ListView 發生。 此事件通常用於取消編輯作業。
ItemInserted 發生于控制項從資料來源插入新記錄之後,將 [ CommandName 插入] 按鈕 (其屬性設定為 「Insert」) 或 InsertNewItem 呼叫 方法時 ListView 。 此事件通常用於檢查插入作業的結果。
ItemInserting 發生于按一下 [插入] 按鈕 (一個按鈕,且其 CommandName 屬性設定為 「Insert」) 或 InsertNewItem 呼叫 方法時,但在控制項插入記錄之前 ListView 。 此事件通常用於取消插入作業或變更或驗證新專案的值。
ItemUpdated 發生于控制項更新記錄之後,將 [更新] 按鈕 (其 CommandName 屬性設定為 [更新] ) 或 UpdateItem 呼叫 方法時 ListView 。 此事件通常用於檢查更新作業的結果。
ItemUpdating 發生于按一下 [更新] 按鈕 (屬性設為 「Update」 ) 的按鈕 CommandName 時,或 UpdateItem 呼叫 方法,但在控制項更新記錄之前 ListView 。 此事件通常用於取消更新作業或變更或驗證編輯專案的值。
LayoutCreated LayoutTemplate 控制項中建立 ListView 樣板時發生。 建立範本之後,通常會使用此事件來執行工作。
PagePropertiesChanged 當頁面屬性變更時,在 ListView 控制項設定新的值之後發生。
PagePropertiesChanging 發生于資料頁屬性變更時,但在控制項設定新值之前 ListView
SelectedIndexChanged 發生于控制項處理選取作業之後,當 [選取] 按鈕 (其 CommandName 屬性設定為 [選取] ) 時 ListView 發生。 這個事件通常用於在控制項中選取專案之後執行自訂工作。
SelectedIndexChanging 發生于按一下 [選取] 按鈕 (其屬性設定為 [選取] ) 的按鈕 CommandName 時,但在控制項處理選取作業之前 ListView 。 此事件通常用於取消選取作業。
Sorted 發生于控制項處理排序作業之後,當 [排序] 按鈕 (其 CommandName 屬性設定為 「Sort」) 或 Sort 呼叫 方法時 ListView 。 當使用者按一下 [排序] 按鈕並排序資料之後,通常會使用此事件來執行自訂工作。
Sorting 發生于按一下 [排序] 按鈕 (其屬性設定為 [排序] ) 的按鈕 CommandName 時,或 Sort 呼叫 方法,但在控制項處理排序作業之前 ListView 。 此事件通常用於取消排序作業,或執行自訂排序常式。

宣告式語法

<asp:ListView
    ConvertEmptyStringToNull="True|False"
    DataKeyNames="string"
    DataMember="string"
    DataSource="string"
    DataSourceID="string"
    EditIndex="integer"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    GroupPlaceholderID="string"
    GroupItemCount="integer"
    ID="string"
    InsertItemPosition="None|FirstItem|LastItem"
    ItemPlaceholderID="string"
    OnDataBinding="DataBinding event handler"
    OnDataBound="DataBound event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnItemCanceling="ItemCanceling event handler"
    OnItemCommand="ItemCommand event handler"
    OnItemCreated="ItemCreated event handler"
    OnItemDataBound="ItemDataBound event handler"
    OnItemDeleted="ItemDeleted event handler"
    OnItemDeleting="ItemDeleting event handler"
    OnItemEditing="ItemEditing event handler"
    OnItemInserted="ItemInserted event handler"
    OnItemInserting="ItemInserting event handler"
    OnItemUpdated="ItemUpdated event handler"
    OnItemUpdating="ItemUpdating event handler"
    OnLayoutCreated="LayoutCreated event handler"
    OnLoad="Load event handler"
    OnPagePropertiesChanged="PagePropertiesChanged event handler"
    OnPagePropertiesChanging="PagePropertiesChanging event handler"
    OnPreRender="PreRender event handler"
    OnSelectedIndexChanged="SelectedIndexChanged event handler"
    OnSelectedIndexChanging="SelectedIndexChanging event handler"
    OnSorted="Sorted event handler"
    OnSorting="Sorting event handler"
    OnUnload="Unload event handler"
    runat="server"
    SelectedIndex="integer"
    SkinID="string"
    Style="string"
    Visible="True|False"
>
        <AlternatingItemTemplate>
            <!-- child controls -->
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <!-- child controls -->
        </EditItemTemplate>
        <EmptyDataTemplate>
            <!-- child controls -->
        </EmptyDataTemplate>
        <EmptyItemTemplate>
            <!-- child controls -->
        </EmptyItemTemplate>
        <GroupSeparatorTemplate>
            <!-- child controls -->
        </GroupSeparatorTemplate>
        <GroupTemplate>
            <!-- child controls -->
        </GroupTemplate>
        <InsertItemTemplate>
            <!-- child controls -->
        </InsertItemTemplate>
        <ItemSeparatorTemplate>
            <!-- child controls -->
        </ItemSeparatorTemplate>
        <ItemTemplate>
            <!-- child controls -->
        </ItemTemplate>
        <LayoutTemplate>
                <!-- child controls -->
        </LayoutTemplate>
        <SelectedItemTemplate>
            <!-- child controls -->
        </SelectedItemTemplate>
</asp:ListView>

建構函式

ListView()

初始化 ListView 類別的新執行個體。

屬性

AccessKey

覆寫 AccessKey 屬性。 ListView 控制項不支援設定這個屬性。

Adapter

針對控制項取得瀏覽器的特定配置器。

(繼承來源 Control)
AlternatingItemTemplate

取得或設定 ListView 控制項中替代資料項目的自訂內容。

AppRelativeTemplateSourceDirectory

取得或設定包含了此控制項之 PageUserControl 物件的相對應用程式虛擬目錄。

(繼承來源 Control)
Attributes

取得任意屬性 (Attribute) 的集合 (只供呈現),不與控制項上的屬性 (Property) 對應。

(繼承來源 WebControl)
BackColor

覆寫 BackColor 屬性。 ListView 控制項不支援設定這個屬性。

BindingContainer

取得包含了此控制項之資料繫結的控制項。

(繼承來源 Control)
BorderColor

覆寫 BorderColor 屬性。 ListView 控制項不支援設定這個屬性。

BorderStyle

覆寫 BorderStyle 屬性。 ListView 控制項不支援設定這個屬性。

BorderWidth

覆寫 BorderWidth 屬性。 ListView 控制項不支援設定這個屬性。

ChildControlsCreated

取得值,指出是否已經建立伺服器控制項的子控制項。

(繼承來源 Control)
ClientID

取得 ASP.NET 所產生之 HTML 標記的控制項識別碼。

(繼承來源 Control)
ClientIDMode

取得或設定用來產生 ClientID 屬性值的演算法。

(繼承來源 Control)
ClientIDRowSuffix

取得或設定資料欄位的名稱,這個資料欄位的值會在 ListView 屬性設為 ClientIDMode 時,用來識別 Predictable 控制項的每個唯一的資料列。

ClientIDRowSuffixDataKeys

取得資料值,這些值會在 ASP.NET 產生 ClientID 值時,用來識別資料繫結控制項的每個唯一的執行個體。

ClientIDSeparator

取得字元值,表示在 ClientID 屬性中所使用的分隔字元。

(繼承來源 Control)
Context

取得與目前 Web 要求的伺服器控制項關聯的 HttpContext 物件。

(繼承來源 Control)
Controls

取得 ControlCollection 物件,這個物件表示 ListView 控制項的子控制項。

ControlStyle

取得 Web 伺服器控制項的樣式。 這個屬性主要由控制項開發人員使用。

(繼承來源 WebControl)
ControlStyleCreated

取得值,指出 Style 物件是否已經為 ControlStyle 屬性建立。 這個屬性主要由控制項開發人員使用。

(繼承來源 WebControl)
ConvertEmptyStringToNull

取得或設定值,表示在資料來源中更新資料欄位時,是否將空字串值 ("") 自動轉換為 null 值。

CssClass

覆寫 CssClass 屬性。 ListView 控制項不支援設定這個屬性。

DataItemContainer

如果命名容器實作 IDataItemContainer,則取得命名容器的參考。

(繼承來源 Control)
DataKeyNames

取得或設定陣列,這個陣列包含 ListView 控制項中所顯示項目的主索引鍵欄位名稱。

DataKeys

取得 DataKey 物件的集合,這些物件表示 ListView 控制項中每一個項目的資料索引鍵值。

DataKeysContainer

如果命名容器實作 IDataKeysControl,則取得命名容器的參考。

(繼承來源 Control)
DataMember

取得或設定資料繫結控制項繫結至的資料清單名稱 (如果資料來源包含多個不同資料項目清單)。

(繼承來源 DataBoundControl)
DataSource

取得或設定資料繫結控制項從中擷取其資料項目清單的物件。

(繼承來源 BaseDataBoundControl)
DataSourceID

取得或設定控制項的識別碼,資料繫結控制項會由此擷取其項目清單。

(繼承來源 DataBoundControl)
DataSourceObject

取得物件,這個物件會實作可提供物件資料內容之存取權的 IDataSource 介面。

(繼承來源 DataBoundControl)
DeleteMethod

為了刪除資料,取得或設定要呼叫的方法名稱。

DesignMode

取得值,指出控制項是否正用於設計介面上。

(繼承來源 Control)
EditIndex

取得或設定正在編輯之項目的索引。

EditItem

取得 ListView 控制項中處於編輯模式的項目。

EditItemTemplate

取得或設定編輯模式中項目的自訂內容。

EmptyDataTemplate

取得或設定空白樣板的使用者定義內容,當 ListView 控制項繫結至不包含任何資料錄的資料來源時會呈現該空白樣板。

EmptyItemTemplate

取得或設定空白項目的使用者定義內容,當目前資料頁的最後一筆資料列已沒有可顯示的資料項目時,ListView 控制項中會呈現該空白項目。

Enabled

取得或設定值,指出 Web 伺服器控制項是否啟用。

(繼承來源 WebControl)
EnableModelValidation

取得或設定值,這個值表示驗證程式控制項是否要處理在插入或更新作業期間發生的例外狀況。

EnablePersistedSelection

取得或設定值,這個值表示當使用者逐頁巡覽資料繫結控制項中的資料時,是否保存資料列選取範圍。

EnableTheming

取得或設定值,指出佈景主題是否套用至此控制項。

(繼承來源 WebControl)
EnableViewState

取得或設定值,該值表示伺服器控制項是否對要求的用戶端而言保持其檢視狀態,以及它包含的任何子控制項狀態。

(繼承來源 Control)
Events

取得控制項事件處理常式委派 (Delegate) 的清單。 這個屬性是唯讀的。

(繼承來源 Control)
Font

覆寫 Font 屬性。 ListView 控制項不支援這個屬性。

ForeColor

覆寫 ForeColor 屬性。 ListView 控制項不支援設定這個屬性。

GroupItemCount

取得或設定 ListView 控制項中每一個群組所顯示的項目數目。

GroupPlaceholderID

取得或設定 ListView 控制項中群組預留位置的 ID。

GroupSeparatorTemplate

取得或設定 ListView 控制項中群組之間分隔符號的使用者定義內容。

GroupTemplate

取得或設定 ListView 控制項中群組容器的使用者定義內容。

HasAttributes

取得值,指出控制項是否已經設定屬性。

(繼承來源 WebControl)
HasChildViewState

取得值,指出目前伺服器控制項的子控制項是否有任何已儲存的檢視狀態設定。

(繼承來源 Control)
Height

覆寫 Height 屬性。 ListView 控制項不支援設定這個屬性。

ID

取得或設定指派給伺服器控制項的程式設計識別項。

(繼承來源 Control)
IdSeparator

取得用來分隔控制項識別項的字元。

(繼承來源 Control)
Initialized

取得值,指出是否已初始化資料繫結控制項。

(繼承來源 BaseDataBoundControl)
InsertItem

取得 ListView 控制項的插入項目。

InsertItemPosition

取得或設定 InsertItemTemplate 樣板在 ListView 控制項中呈現的位置。

InsertItemTemplate

取得或設定 ListView 控制項中的插入項目的自訂內容。

InsertMethod

為了插入資料,取得或設定要呼叫的方法名稱。

IsBoundUsingDataSourceID

取得值,指出是否已設定 DataSourceID 屬性。

(繼承來源 BaseDataBoundControl)
IsChildControlStateCleared

取得值,指出這個控制項中所包含的控制項是否有控制項狀態。

(繼承來源 Control)
IsDataBindingAutomatic

取得值,指出資料繫結是否為自動。

(繼承來源 BaseDataBoundControl)
IsEnabled

取得值,指出是否啟用控制項。

(繼承來源 WebControl)
IsTrackingViewState

取得值,指出伺服器控制項是否正在儲存檢視狀態的變更。

(繼承來源 Control)
IsUsingModelBinders

取得值,指出模型繫結是否正在使用。

IsUsingModelBinders

取得值,指出模型繫結是否正在使用。

(繼承來源 DataBoundControl)
IsViewStateEnabled

取得值,指出這個控制項是否已啟用檢視狀態。

(繼承來源 Control)
ItemPlaceholderID

取得或設定 ListView 控制項中項目預留位置的 ID。

Items

取得 ListViewDataItem 物件的集合,這些物件表示 ListView 控制項中目前資料頁的資料項目。

ItemSeparatorTemplate

取得或設定 ListView 控制項中項目之間分隔符號的自訂內容。

ItemTemplate

取得或設定 ListView 控制項中資料項目的自訂內容。

ItemType

取得或設定強型別資料繫結的資料項目型別名稱。

(繼承來源 DataBoundControl)
LayoutTemplate

取得或設定 ListView 控制項中根容器的自訂內容。

LoadViewStateByID

取得值,指出控制項是否依 ID (而不是索引) 參與載入其檢視狀態。

(繼承來源 Control)
MaximumRows

取得在 ListView 控制項的單一頁面上顯示的項目最大數目。

NamingContainer

取得伺服器控制項命名容器的參考,其建立唯一命名空間,在具有相同 ID 屬性值的伺服器控制項之間作區別。

(繼承來源 Control)
Page

取得含有伺服器控制項的 Page 執行個體的參考。

(繼承來源 Control)
Parent

在網頁控制階層架構中取得伺服器控制項之父控制項的參考。

(繼承來源 Control)
RenderingCompatibility

取得值,這個值會指定將與呈現 HTML 相容的 ASP.NET 版本。

(繼承來源 Control)
RequiresDataBinding

取得或設定值,指出是否應該呼叫 DataBind() 方法。

(繼承來源 BaseDataBoundControl)
SelectArguments

取得 DataSourceSelectArguments 物件,當從資料來源控制項擷取資料時資料繫結控制項會使用它。

(繼承來源 DataBoundControl)
SelectedDataKey

取得 ListView 控制項中所選取項目的資料索引鍵值。

SelectedIndex

取得或設定 ListView 控制項中所選取項目的索引。

SelectedItemTemplate

取得或設定 ListView 控制項中選取之項目的自訂內容。

SelectedPersistedDataKey

為資料繫結控制項中持續選取的項目,取得或設定資料索引鍵值。

SelectedValue

取得 ListView 控制項中選取之項目的資料索引鍵值。

SelectMethod

為了讀取資料要呼叫的方法的名稱。

(繼承來源 DataBoundControl)
Site

當呈現在設計介面上時,取得裝載目前控制項之容器的資訊。

(繼承來源 Control)
SkinID

取得或設定要套用至控制項的面板。

(繼承來源 WebControl)
SortDirection

取得目前排序之欄位的排序方向。

SortExpression

取得與目前排序的欄位相關聯的排序運算式。

StartRowIndex

取得 ListView 控制項中的資料頁所顯示之第一筆資料錄的索引。

Style

取得文字屬性的集合,將呈現為 Web 伺服器控制項的外部標記上的樣式屬性。

(繼承來源 WebControl)
SupportsDisabledAttribute

取得值,這個值表示當控制項的 disabled 屬性為 IsEnabled 時,控制項是否應該將呈現之 HTML 項目的 false 屬性設為 "disabled"。

(繼承來源 BaseDataBoundControl)
TabIndex

覆寫 TabIndex 屬性。 ListView 控制項不支援設定這個屬性。

TagKey

取得對應至這個 Web 伺服器控制項的 HtmlTextWriterTag 值。 這個屬性主要由控制項開發人員使用。

(繼承來源 WebControl)
TagName

取得控制項標記的名稱。 這個屬性主要由控制項開發人員使用。

(繼承來源 WebControl)
TemplateControl

取得或設定包含了此控制項之樣板的參考。

(繼承來源 Control)
TemplateSourceDirectory

取得包含目前伺服器控制項的 PageUserControl 的虛擬目錄。

(繼承來源 Control)
ToolTip

覆寫 ToolTip 屬性。 ListView 控制項不支援設定這個屬性。

UniqueID

取得伺服器控制項唯一的、符合階層架構的識別項。

(繼承來源 Control)
UpdateMethod

為了更新資料,取得或設定要呼叫的方法名稱。

ValidateRequestMode

取得或設定值,指出控制項是否對來自瀏覽器的用戶端輸入檢查潛在的危險值。

(繼承來源 Control)
ViewState

取得狀態資訊的字典,允許您在相同網頁的多個要求之間,儲存和還原伺服器控制項的檢視狀態。

(繼承來源 Control)
ViewStateIgnoresCase

取得值,指出 StateBag 物件是否不區分大小寫。

(繼承來源 Control)
ViewStateMode

取得或設定這個控制項的檢視狀態模式。

(繼承來源 Control)
Visible

取得或設定值,指出伺服器控制項是否會轉譯為頁面上的 UI。

(繼承來源 Control)
Width

覆寫 Width 屬性。 ListView 控制項不支援設定這個屬性。

方法

AddAttributesToRender(HtmlTextWriter)

將需要呈現的 HTML 屬性和樣式加入至指定的 HtmlTextWriterTag 中。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
AddControlToContainer(Control, Control, Int32)

將指定的控制項加入至指定的容器。

AddedControl(Control, Int32)

在子控制項加入 Control 物件的 Controls 集合後呼叫。

(繼承來源 Control)
AddParsedSubObject(Object)

通知伺服器控制項,XML 或 HTML 項目已剖析,並將項目加入伺服器控制項的 ControlCollection 物件中。

(繼承來源 Control)
ApplyStyle(Style)

將指定樣式的任何非空白項目加入到 Web 控制項中,覆寫控制項的任何現有的樣式項目。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
ApplyStyleSheetSkin(Page)

將頁面樣式表中所定義的樣式屬性套用至控制項。

(繼承來源 Control)
BeginRenderTracing(TextWriter, Object)

開始進行轉譯資料的設計階段追蹤。

(繼承來源 Control)
BuildProfileTree(String, Boolean)

收集伺服器控制項的相關資訊,並在頁面啟用追蹤時將此資訊傳遞至 Trace 屬性以顯示之。

(繼承來源 Control)
ClearCachedClientID()

將快取的 ClientID 值設定為 null

(繼承來源 Control)
ClearChildControlState()

刪除伺服器控制項之子控制項的控制項狀態資訊。

(繼承來源 Control)
ClearChildState()

刪除所有伺服器控制項之子控制項的檢視狀態和控制項狀態資訊。

(繼承來源 Control)
ClearChildViewState()

刪除所有伺服器控制項之子控制項的檢視狀態資訊。

(繼承來源 Control)
ClearEffectiveClientIDMode()

將目前的控制項執行個體和任何子控制項的 ClientIDMode 屬性設定為 Inherit

(繼承來源 Control)
ConfirmInitState()

設定資料繫結控制項之初始化的狀態。

(繼承來源 BaseDataBoundControl)
CopyBaseAttributes(WebControl)

將不被 Style 物件封裝的屬性從指定的 Web 伺服器控制項複製到呼叫這個方法的 Web 伺服器控制項上。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
CreateChildControls()

根據檢視狀態中儲存的值,建立用於呈現 ListView 控制項的控制階層架構。

CreateChildControls(IEnumerable, Boolean)

使用特定資料來源建立用於呈現 ListView 控制項的控制階層架構。

CreateControlCollection()

建立新的 ControlCollection 物件來保存伺服器控制項的子控制項 (常值和伺服器)。

(繼承來源 Control)
CreateControlStyle()

建立控制項的預設樣式。

CreateDataItem(Int32, Int32)

ListView 控制項中建立資料項目。

CreateDataSourceSelectArguments()

建立 DataSourceSelectArguments 物件,這個物件包含傳遞至資料來源的引數。

CreateEmptyDataItem()

EmptyDataTemplate 控制項中建立 ListView 樣板。

CreateEmptyItem()

ListView 控制項中建立空白項目。

CreateInsertItem()

ListView 控制項中建立插入項目。

CreateItem(ListViewItemType)

建立指定之型別的 ListViewItem 物件。

CreateItemsInGroups(ListViewPagedDataSource, Boolean, InsertItemPosition, ArrayList)

分組建立 ListView 控制階層架構。

CreateItemsWithoutGroups(ListViewPagedDataSource, Boolean, InsertItemPosition, ArrayList)

建立不分組的 ListView 控制階層架構。

CreateLayoutTemplate()

ListView 控制項中建立根容器。

CreateSuffixArrayList(ListViewPagedDataSource, ArrayList)

建立尾碼陣列,供 ASP.NET 在產生 ClientID 值時使用。

DataBind()

將資料來源繫結至所叫用的伺服器控制項及其所有子控制項。

(繼承來源 BaseDataBoundControl)
DataBind(Boolean)

使用會引發 DataBinding 事件的選項,繫結資料來源至叫用的伺服器控制項及其所有子控制項。

(繼承來源 Control)
DataBindChildren()

繫結資料來源至伺服器控制項的子控制項。

(繼承來源 Control)
DeleteItem(Int32)

刪除資料來源中指定索引的資料錄。

Dispose()

啟用伺服器控制項,在它從記憶體釋放之前執行最後清除。

(繼承來源 Control)
EndRenderTracing(TextWriter, Object)

結束轉譯資料的設計階段追蹤。

(繼承來源 Control)
EnsureChildControls()

判斷伺服器控制項是否包含子控制項。 如果不包含,則建立子控制項。

(繼承來源 Control)
EnsureDataBound()

如果設定了 DataBind() 屬性且資料繫結控制項標記為需要繫結,則會呼叫 DataSourceID 方法。

(繼承來源 BaseDataBoundControl)
EnsureID()

為尚未指定識別項的控制項,建立識別項。

(繼承來源 Control)
EnsureLayoutTemplate()

確定已在 LayoutTemplate 控制項中建立正確的 ListView 內容。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
ExtractItemValues(IOrderedDictionary, ListViewItem, Boolean)

擷取指定之項目中宣告的每一個欄位的值,並儲存在指定的 IOrderedDictionary 物件中。

FindControl(String)

在目前命名容器搜尋具有指定 id 參數的伺服器控制項。

(繼承來源 Control)
FindControl(String, Int32)

使用指定的 id 和有助於搜尋之 pathOffset 參數中所指定的整數,在目前的命名容器中搜尋伺服器控制項。 您不應該覆寫這個版本的 FindControl 方法。

(繼承來源 Control)
FindPlaceholder(String, Control)

在指定的容器中搜尋具有指定之識別項的控制項。

Focus()

設定控制項的輸入焦點。

(繼承來源 Control)
GetData()

擷取 DataSourceView 物件,資料繫結控制項會用來執行資料作業。

(繼承來源 DataBoundControl)
GetDataSource()

擷取與資料繫結控制項關聯的 IDataSource 介面 (如果有的話)。

(繼承來源 DataBoundControl)
GetDesignModeState()

取得控制項的設計階段資料。

(繼承來源 Control)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetRouteUrl(Object)

取得會對應於一組路由參數的 URL。

(繼承來源 Control)
GetRouteUrl(RouteValueDictionary)

取得會對應於一組路由參數的 URL。

(繼承來源 Control)
GetRouteUrl(String, Object)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。

(繼承來源 Control)
GetRouteUrl(String, RouteValueDictionary)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。

(繼承來源 Control)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetUniqueIDRelativeTo(Control)

傳回指定之控制項 UniqueID 屬性的前置部分。

(繼承來源 Control)
HasControls()

判斷伺服器控制項是否包含任何子控制項。

(繼承來源 Control)
HasEvents()

傳回值,指出控制項或任何子控制項的事件是否已註冊。

(繼承來源 Control)
InsertNewItem(Boolean)

將目前的資料錄插入資料來源。

InstantiateEmptyDataTemplate(Control)

使用 Control 樣板包含的子控制項,填入指定的 EmptyDataTemplate 物件。

InstantiateEmptyItemTemplate(Control)

使用 Control 樣板包含的子控制項,填入指定的 EmptyItemTemplate 物件。

InstantiateGroupSeparatorTemplate(Control)

使用 Control 樣板包含的子控制項,填入指定的 GroupSeparatorTemplate 物件。

InstantiateGroupTemplate(Control)

使用 Control 樣板包含的子控制項,填入指定的 GroupTemplate 物件。

InstantiateInsertItemTemplate(Control)

使用 Control 樣板包含的子控制項,填入指定的 InsertItemTemplate 物件。

InstantiateItemSeparatorTemplate(Control)

使用 Control 樣板包含的子控制項,填入指定的 ItemSeparatorTemplate 物件。

InstantiateItemTemplate(Control, Int32)

使用其中一個 Control 控制項樣板中的子控制項,填入指定的 ListView 物件。

IsLiteralContent()

判斷伺服器控制項是否只儲存常值內容。

(繼承來源 Control)
LoadControlState(Object)

載入 ListView 控制項中必須保存的屬性狀態,即使 EnableViewState 屬性設定為 false 也一樣。

LoadViewState(Object)

載入先前儲存的 ListView 控制項檢視狀態。

MapPathSecure(String)

擷取虛擬絕對路徑或相對路徑所對應至的實體路徑。

(繼承來源 Control)
MarkAsDataBound()

將檢視狀態中的控制項狀態設為已成功繫結至資料。

(繼承來源 DataBoundControl)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MergeStyle(Style)

將指定樣式的任何非空白項目複製到 Web 控制項,但不覆寫控制項的任何現有樣式項目。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
OnBubbleEvent(Object, EventArgs)

決定是否應該處理 ListView 控制項的事件。

OnCreatingModelDataSource(CreatingModelDataSourceEventArgs)

引發 CreatingModelDataSource 事件。

(繼承來源 DataBoundControl)
OnDataBinding(EventArgs)

引發 DataBinding 事件。

(繼承來源 Control)
OnDataBound(EventArgs)

引發 DataBound 事件。

(繼承來源 BaseDataBoundControl)
OnDataPropertyChanged()

其中一個基底資料來源識別屬性變更之後,將資料繫結控制項重新繫結至其資料。

(繼承來源 DataBoundControl)
OnDataSourceViewChanged(Object, EventArgs)

引發 DataSourceViewChanged 事件。

(繼承來源 DataBoundControl)
OnInit(EventArgs)

引發 Init 事件。

OnItemCanceling(ListViewCancelEventArgs)

引發 ItemCanceling 事件。

OnItemCommand(ListViewCommandEventArgs)

引發 ItemCommand 事件。

OnItemCreated(ListViewItemEventArgs)

引發 ItemCreated 事件。

OnItemDataBound(ListViewItemEventArgs)

引發 ItemDataBound 事件。

OnItemDeleted(ListViewDeletedEventArgs)

引發 ItemDeleted 事件。

OnItemDeleting(ListViewDeleteEventArgs)

引發 ItemDeleting 事件。

OnItemEditing(ListViewEditEventArgs)

引發 ItemEditing 事件。

OnItemInserted(ListViewInsertedEventArgs)

引發 ItemInserted 事件。

OnItemInserting(ListViewInsertEventArgs)

引發 ItemInserting 事件。

OnItemUpdated(ListViewUpdatedEventArgs)

引發 ItemUpdated 事件。

OnItemUpdating(ListViewUpdateEventArgs)

引發 ItemUpdating 事件。

OnLayoutCreated(EventArgs)

引發 LayoutCreated 事件。

OnLoad(EventArgs)

處理 Load 事件。

(繼承來源 DataBoundControl)
OnPagePreLoad(Object, EventArgs)

設定資料繫結控制項在載入控制項之前的初始化狀態。

(繼承來源 DataBoundControl)
OnPagePropertiesChanged(EventArgs)

引發 PagePropertiesChanged 事件。

OnPagePropertiesChanging(PagePropertiesChangingEventArgs)

引發 PagePropertiesChanging 事件。

OnPreRender(EventArgs)

處理 PreRender 事件。

(繼承來源 BaseDataBoundControl)
OnSelectedIndexChanged(EventArgs)

引發 SelectedIndexChanged 事件。

OnSelectedIndexChanging(ListViewSelectEventArgs)

引發 SelectedIndexChanging 事件。

OnSorted(EventArgs)

引發 Sorted 事件。

OnSorting(ListViewSortEventArgs)

引發 Sorting 事件。

OnTotalRowCountAvailable(PageEventArgs)

引發 IPageableItemContainer.TotalRowCountAvailable 事件。

OnUnload(EventArgs)

引發 Unload 事件。

(繼承來源 Control)
OpenFile(String)

取得用來讀取檔案的 Stream

(繼承來源 Control)
PerformDataBinding(IEnumerable)

ListView 控制項繫結至指定的資料來源。

PerformSelect()

從關聯的資料來源擷取資料。

RaiseBubbleEvent(Object, EventArgs)

指派事件的任何來源和它的資訊至控制項的父控制項。

(繼承來源 Control)
RemovedControl(Control)

Control 物件的 Controls 集合中移除子控制項之後呼叫。

(繼承來源 Control)
RemoveItems()

刪除 ListView 控制項的項目容器或群組容器中的所有子控制項。

Render(HtmlTextWriter)

使用指定的 HtmlTextWriter 物件,向用戶端瀏覽器呈現 Web 伺服器控制項內容。

RenderBeginTag(HtmlTextWriter)

將控制項的 HTML 開頭標記呈現在指定的寫入器中。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
RenderChildren(HtmlTextWriter)

將伺服器控制項子系的內容輸出至提供的 HtmlTextWriter 物件,再由這個物件在用戶端上寫入要轉譯的內容。

(繼承來源 Control)
RenderContents(HtmlTextWriter)

將控制項的內容呈現在指定的寫入器。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
RenderControl(HtmlTextWriter)

將伺服器控制項內容輸出至提供的 HtmlTextWriter 物件,並在啟用追蹤時儲存控制項的追蹤資訊。

(繼承來源 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

使用提供的 HtmlTextWriter 物件,輸出伺服器控制項內容至提供的 ControlAdapter 物件。

(繼承來源 Control)
RenderEndTag(HtmlTextWriter)

將控制項的 HTML 結尾標記呈現至指定的寫入器。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
ResolveAdapter()

取得負責呈現指定之控制項的控制項配置器。

(繼承來源 Control)
ResolveClientUrl(String)

取得瀏覽器可使用的 URL。

(繼承來源 Control)
ResolveUrl(String)

將 URL 轉換為要求用戶端可使用的 URL。

(繼承來源 Control)
SaveControlState()

儲存 ListView 控制項中需要保存的屬性狀態,即使 EnableViewState 屬性設定為 false 也一樣。

SaveViewState()

儲存 ListView 控制項的目前檢視狀態。

SelectItem(Int32)

選取 ListView 控制項中處於編輯模式的項目。

SetDesignModeState(IDictionary)

設定控制項的設計階段資料。

(繼承來源 Control)
SetEditItem(Int32)

ListView 控制項中指定的項目設為編輯模式。

SetPageProperties(Int32, Int32, Boolean)

設定 ListView 控制項中資料頁的屬性。

SetRenderMethodDelegate(RenderMethod)

指定事件處理常式委派,以呈現伺服器控制項及其內容至其父控制項。

(繼承來源 Control)
SetTraceData(Object, Object)

使用追蹤資料機碼和追蹤資料值,設定設計階段期間追蹤呈現資料的追蹤資料。

(繼承來源 Control)
SetTraceData(Object, Object, Object)

使用追蹤的物體、追蹤資料機碼和追蹤資料值,設定設計階段期間追蹤呈現資料的追蹤資料。

(繼承來源 Control)
Sort(String, SortDirection)

根據指定的排序運算式和方向,排序 ListView 控制項。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
TrackViewState()

導致對控制項的檢視狀態變更進行追蹤,以便它們能夠儲存於控制項的 StateBag 物件。

(繼承來源 DataBoundControl)
UpdateItem(Int32, Boolean)

在資料來源中更新指定之索引上的資料錄。

ValidateDataSource(Object)

驗證資料繫結控制項繫結至的物件是該資料繫結控制項所使用的物件。

(繼承來源 DataBoundControl)

事件

CallingDataMethods

正在呼叫資料方法時發生。

(繼承來源 DataBoundControl)
CreatingModelDataSource

正在建立 ModelDataSource 物件時發生。

(繼承來源 DataBoundControl)
DataBinding

發生於伺服器控制項繫結至資料來源時。

(繼承來源 Control)
DataBound

在伺服器控制項繫結至資料來源之後發生。

(繼承來源 BaseDataBoundControl)
Disposed

發生於伺服器控制項從記憶體釋放時,這是在要求 ASP.NET 網頁時,伺服器控制項生命週期的最後階段。

(繼承來源 Control)
Init

發生於初始化伺服器控制項時,是其生命週期中的第一個步驟。

(繼承來源 Control)
ItemCanceling

當要求取消作業時,但是在 ListView 控制項取消插入或編輯作業之前發生。

ItemCommand

當按一下 ListView 控制項中的按鈕時發生。

ItemCreated

ListView 控制項中建立項目時發生。

ItemDataBound

當資料項目繫結至 ListView 控制項中的資料時發生。

ItemDeleted

當要求刪除作業時,在 ListView 控制項刪除項目之後發生。

ItemDeleting

當要求刪除作業時,但是在 ListView 控制項刪除項目之前發生。

ItemEditing

當要求編輯作業時,在 ListView 項目進入編輯模式之前發生。

ItemInserted

當要求插入作業時,在 ListView 控制項將項目插入資料來源之後發生。

ItemInserting

當要求插入作業時,但是在 ListView 控制項執行插入之前發生。

ItemUpdated

當要求更新作業時,在 ListView 控制項更新項目之後發生。

ItemUpdating

當要求更新作業時,但是在 ListView 控制項更新項目之前發生。

LayoutCreated

LayoutTemplate 控制項中建立 ListView 樣板時發生。

Load

發生於載入伺服器控制項至 Page 物件時。

(繼承來源 Control)
PagePropertiesChanged

當頁面屬性變更時,在 ListView 控制項設定新的值之後發生。

PagePropertiesChanging

當頁面屬性變更時,但是在 ListView 控制項設定新的值之前發生。

PreRender

Control 物件載入之後但在呈現之前發生。

(繼承來源 Control)
SelectedIndexChanged

當按一下項目的 [選取] 按鈕時,在 ListView 控制項處理選取作業之後發生。

SelectedIndexChanging

當按一下項目的 [選取] 按鈕時,但是在 ListView 控制項處理選取作業之後發生。

Sorted

當要求排序作業時,在 ListView 控制項處理排序作業之後發生。

Sorting

當要求排序作業時,但是在 ListView 控制項處理排序作業之前發生。

Unload

發生於伺服器控制項從記憶體卸載時。

(繼承來源 Control)

明確介面實作

IAttributeAccessor.GetAttribute(String)

使用指定的名稱,取得 Web 控制項的屬性。

(繼承來源 WebControl)
IAttributeAccessor.SetAttribute(String, String)

將 Web 控制項的屬性設定為指定的名稱和值。

(繼承來源 WebControl)
IControlBuilderAccessor.ControlBuilder

如需這個成員的說明,請參閱 ControlBuilder

(繼承來源 Control)
IControlDesignerAccessor.GetDesignModeState()

如需這個成員的說明,請參閱 GetDesignModeState()

(繼承來源 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

如需這個成員的說明,請參閱 SetDesignModeState(IDictionary)

(繼承來源 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

如需這個成員的說明,請參閱 SetOwnerControl(Control)

(繼承來源 Control)
IControlDesignerAccessor.UserData

如需這個成員的說明,請參閱 UserData

(繼承來源 Control)
IDataBindingsAccessor.DataBindings

如需這個成員的說明,請參閱 DataBindings

(繼承來源 Control)
IDataBindingsAccessor.HasDataBindings

如需這個成員的說明,請參閱 HasDataBindings

(繼承來源 Control)
IDataBoundControl.DataKeyNames

取得或設定陣列,這個陣列包含資料繫結控制項中所顯示項目的主索引鍵欄位名稱。

IDataBoundControl.DataMember

取得或設定資料清單的名稱,當資料來源包含多個不同資料項目清單時,資料繫結控制項會繫結至這個資料清單。

IDataBoundControl.DataSource

取得或設定物件,資料繫結控制項會從這個物件擷取資料項目清單。

IDataBoundControl.DataSourceID

取得或設定資料來源控制項的 ID,資料繫結控制項會從這個資料來源控制項擷取資料項目清單。

IDataBoundControl.DataSourceObject

取得物件,這個物件會實作可提供物件資料內容之存取權的 IDataSource 介面。

IDataBoundListControl.ClientIDRowSuffix

取得資料欄位的名稱,這個資料欄位的值會在 ListView 屬性設為 ClientIDMode 時,用來識別 Predictable 控制項的每個唯一的資料列。

IDataBoundListControl.DataKeys

取得資料索引鍵值的集合,這些資料索引鍵值表示資料繫結控制項中的每個資料列。

IDataBoundListControl.EnablePersistedSelection

取得或設定值,這個值指定當使用者逐頁巡覽資料繫結控制項中的資料時,是否保存某個資料列的選取狀態。

IDataBoundListControl.SelectedDataKey

取得資料索引鍵物件,這個物件包含資料繫結控制項中所選取資料列的資料索引鍵值。

IDataBoundListControl.SelectedIndex

取得或設定資料繫結控制項中所選取資料列的索引。

IDataKeysControl.ClientIDRowSuffixDataKeys

取得資料值集合,這些值會在 ASP.NET 產生 ClientID 值時,用來識別資料繫結控制項的每個唯一的執行個體。

IExpressionsAccessor.Expressions

如需這個成員的說明,請參閱 Expressions

(繼承來源 Control)
IExpressionsAccessor.HasExpressions

如需這個成員的說明,請參閱 HasExpressions

(繼承來源 Control)
IPageableItemContainer.MaximumRows

如需這個成員的說明,請參閱 MaximumRows

IPageableItemContainer.SetPageProperties(Int32, Int32, Boolean)

如需這個成員的說明,請參閱 SetPageProperties(Int32, Int32, Boolean)

IPageableItemContainer.StartRowIndex

如需這個成員的說明,請參閱 StartRowIndex

IPageableItemContainer.TotalRowCountAvailable

如需這個成員的說明,請參閱 TotalRowCountAvailable

IParserAccessor.AddParsedSubObject(Object)

如需這個成員的說明,請參閱 AddParsedSubObject(Object)

(繼承來源 Control)
IPersistedSelector.DataKey

取得或設定資料繫結控制項中所選取資料錄的資料索引鍵值。

擴充方法

EnablePersistedSelection(BaseDataBoundControl)
已淘汰.

啟用要保存於資料控制項中且支援選取和分頁的選項。

FindDataSourceControl(Control)

傳回與指定之控制項的資料控制項相關聯的資料來源。

FindFieldTemplate(Control, String)

傳回在指定之控制項的命名容器中所指定資料行的欄位樣板。

FindMetaTable(Control)

傳回包含資料控制項的中繼資料表物件。

GetDefaultValues(INamingContainer)

取得所指定資料控制項的預設值集合。

GetMetaTable(INamingContainer)

取得所指定資料控制項中的資料表中繼資料。

SetMetaTable(INamingContainer, MetaTable)

設定所指定資料控制項中的資料表中繼資料。

SetMetaTable(INamingContainer, MetaTable, IDictionary<String,Object>)

設定所指定資料控制項的資料表中繼資料及預設值對應。

SetMetaTable(INamingContainer, MetaTable, Object)

設定所指定資料控制項的資料表中繼資料及預設值對應。

TryGetMetaTable(INamingContainer, MetaTable)

判斷資料表中繼資料是否可供使用。

EnableDynamicData(INamingContainer, Type)

針對指定的資料控制項啟用動態資料行為。

EnableDynamicData(INamingContainer, Type, IDictionary<String,Object>)

針對指定的資料控制項啟用動態資料行為。

EnableDynamicData(INamingContainer, Type, Object)

針對指定的資料控制項啟用動態資料行為。

適用於

另請參閱