DataControlField.Visible Property
Assembly: System.Web (in system.web.dll)
/** @property */ public boolean get_Visible () /** @property */ public void set_Visible (boolean value)
public function get Visible () : boolean public function set Visible (value : boolean)
Property Value
true if the DataControlField is rendered; otherwise, false. The default value is true.Use the Visible property to show or hide DataControlField objects in a data-bound control.
If the the Visible property is false, the data values are not displayed and do not make a round-trip to the client. 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.
The following code example demonstrates how to use BoundField and ButtonField objects, which are derived from DataControlField, to display rows in a DetailsView control. 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="VJ#" %>
<html>
<body>
<form 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="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind">
</asp:sqldatasource>
</form>
</body>
</html>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.