asp.net.ph

DataControlField.ControlStyle Property

System.Web.UI.WebControls Namespace   DataControlField Class


.NET Framework version 2.0

Sets or retrieves the style properties of server controls contained in a DataControlField.

Syntax


Script DataControlField.ControlStyle.Property [ = enumValue ]

Property Value

A Style that defines the style properties of server controls contained in a DataControlField.

Remarks

Use the ControlStyle property to provide a custom style for server controls contained in types that derive from the DataControlField class. Common style attributes that can be set include forecolor, backcolor, font, and content alignment within the field.

This property does not affect all derived types. For example, the BoundField control typically displays text data and contains only TextBox controls, and is only affected by the ControlStyle property when in edit mode.

Field types such as ButtonField and CheckBoxField can be affected by the ControlStyle property, depending on the specific configuration of the controls contained in the field. For example, the ButtonField control can be rendered as a Button, LinkButton, or ImageButton control. While a LinkButton is affected by font attributes, a Button control is not.

The ControlStyle subproperties can be set declaratively using either of the following methods:

  • Include an attribute in the opening tag of the DataControlField control in the form ControlStyle-Property
    <asp:datacontrolfield ... 
       controlstyle-property=value
       ... >
    
    </asp:datacontrolfield>
  • Include a <ControlStyle> element between the opening and closing tags of the DataControlField control
    <asp:datacontrolfield ... >
    
       <controlstyle
          ... property definitions here />
    
    </asp:datacontrolfield>

The subproperties can also be set programmatically in the form ControlStyle.Property.

For a list of style properties that can be set, see the Style class.

Example

The following examples demonstrate using the ControlStyle property in different scenarios.

Dynamically Generated ButtonField ImageButtons
Run Sample | View Source
Dynamically Generated HyperLinkField Images
Run Sample | View Source
DetailsView PagerSettings, PagerStyle Example
Run Sample | View Source
See Also

DataControlField Members   FooterStyle   HeaderStyle   ItemStyle Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph