DataControlField.Visible プロパティ
定義
データ コントロール フィールドを表示するかどうかを示す値を取得または設定します。Gets or sets a value indicating whether a data control field is rendered.
public:
property bool Visible { bool get(); void set(bool value); };
public bool Visible { get; set; }
member this.Visible : bool with get, set
Public Property Visible As Boolean
プロパティ値
DataControlField が表示される場合は true
。それ以外の場合は false
。true
if the DataControlField is rendered; otherwise, false
. 既定値は true
です。The default value is true
.
例
次のコード例は、 BoundField から派生したオブジェクトとオブジェクトを使用して、 ButtonField DataControlField コントロールの行を表示する方法を示して DetailsView います。The following code example demonstrates how to use BoundField and ButtonField objects, which are derived from DataControlField, to display rows in a DetailsView control. Visible BoundField 列を表示するオブジェクトのプロパティ EmployeeID
はに設定され、列は false
コントロールによって表示されません DetailsView 。The Visible property of the BoundField object that displays the EmployeeID
column is set to false
, and the column is not rendered by the DetailsView control.
<%@ 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>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:detailsview
id="DetailsView1"
runat="server"
allowpaging="True"
datasourceid="SqlDataSource1"
autogeneraterows="False"
width="312px"
height="152px">
<fields>
<asp:boundfield
visible="False"
sortexpression="EmployeeID"
datafield="EmployeeID">
</asp:boundfield>
<asp:boundfield
sortexpression="LastName"
datafield="LastName"
headertext="LastName">
</asp:boundfield>
<asp:boundfield
sortexpression="FirstName"
datafield="FirstName"
headertext="FirstName">
</asp:boundfield>
<asp:boundfield
sortexpression="Title"
datafield="Title"
headertext="Title">
</asp:boundfield>
<asp:buttonfield text="Button">
<controlstyle font-bold="True" forecolor="Red" />
</asp:buttonfield>
</fields>
</asp:detailsview>
<asp:sqldatasource
id="SqlDataSource1"
runat="server"
selectcommand="SELECT * FROM Employees"
connectionstring="<%$ ConnectionStrings:MyNorthwind%>">
</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>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:detailsview
id="DetailsView1"
runat="server"
allowpaging="True"
datasourceid="SqlDataSource1"
autogeneraterows="False"
width="312px"
height="152px">
<fields>
<asp:boundfield
visible="False"
sortexpression="EmployeeID"
datafield="EmployeeID">
</asp:boundfield>
<asp:boundfield
sortexpression="LastName"
datafield="LastName"
headertext="LastName">
</asp:boundfield>
<asp:boundfield
sortexpression="FirstName"
datafield="FirstName"
headertext="FirstName">
</asp:boundfield>
<asp:boundfield
sortexpression="Title"
datafield="Title"
headertext="Title">
</asp:boundfield>
<asp:buttonfield text="Button">
<controlstyle font-bold="True" forecolor="Red" />
</asp:buttonfield>
</fields>
</asp:detailsview>
<asp:sqldatasource
id="SqlDataSource1"
runat="server"
selectcommand="SELECT * FROM Employees"
connectionstring="<%$ ConnectionStrings:MyNorthwind%>">
</asp:sqldatasource>
</form>
</body>
</html>
注釈
プロパティを使用して、 Visible DataControlField データバインドコントロール内のオブジェクトの表示と非表示を切り替えます。Use the Visible property to show or hide DataControlField objects in a data-bound control.
Visibleプロパティがの場合 false
、データ値は表示されず、クライアントへのラウンドトリップを行いません。If the Visible property is false
, the data values are not displayed and do not make a round-trip to the client. 表示されていないフィールドのデータをラウンドトリップする場合は、 DataKeyNames
データバインドコントロールのプロパティにフィールド名を追加します。If you want to round-trip the data for a field that is not visible, add the field name to the DataKeyNames
property of the data-bound control.