DetailsView.GridLines 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 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。 下表列出了可用的样式。
Style | 说明 |
---|---|
GridLines.None |
不显示网格线。 |
GridLines.Horizontal |
仅显示水平网格线。 |
GridLines.Vertical |
仅显示垂直网格线。 |
GridLines.Both |
显示水平网格线和垂直网格线。 |