DetailsView.GridLines 屬性

定義

取得或設定 DetailsView 控制項的格線樣式。

public:
 virtual property System::Web::UI::WebControls::GridLines GridLines { System::Web::UI::WebControls::GridLines get(); void set(System::Web::UI::WebControls::GridLines value); };
public virtual System.Web.UI.WebControls.GridLines GridLines { get; set; }
member this.GridLines : System.Web.UI.WebControls.GridLines with get, set
Public Overridable Property GridLines As GridLines

屬性值

其中一個 GridLines 值。 預設值為 GridLines.Both

範例

下列程式碼範例示範如何使用 GridLines 屬性來隱藏 控制項中的所有 DetailsView 格線。


<%@ 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>DetailsView GridLines Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView GridLines Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          autogeneraterows="true"
          allowpaging="true"
          gridlines="None"  
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <!-- 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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"

          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </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>DetailsView GridLines Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView GridLines Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          autogeneraterows="true"
          allowpaging="true"
          gridlines="None"  
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <!-- 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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"

          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
  </body>
</html>

備註

GridLines使用 屬性來指定控制項的格線樣式 DetailsView 。 下表列出可用的樣式。

樣式 描述
GridLines.None 不會顯示格線。
GridLines.Horizontal 只顯示水準格線。
GridLines.Vertical 只顯示垂直格線。
GridLines.Both 顯示水準和垂直格線。

適用於

另請參閱