DataControlField.Visible Property
.NET Framework 3.0
Gets or sets a value indicating whether a data control field is rendered.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
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)
Not applicable.
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#" %>
<!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="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind">
</asp:sqldatasource>
</form>
</body>
</html>
Community Additions
ADD
Show: