Language

DataControlField.ControlStyle プロパティ

定義

DataControlField オブジェクトに含まれる Web サーバー コントロールのスタイルを取得します。

public:
 property System::Web::UI::WebControls::Style ^ ControlStyle { System::Web::UI::WebControls::Style ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.Style ControlStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.ControlStyle : System.Web.UI.WebControls.Style
Public ReadOnly Property ControlStyle As Style

プロパティ値

フィールドに含まれる Web サーバー コントロールの外観を制御する Style 。

属性

例

次のコード例では、BoundFieldから派生したButtonFieldオブジェクトとDataControlField オブジェクトを使用して、DetailsView コントロール内の行を表示する方法を示します。 ControlStyle オブジェクトのButtonFieldプロパティが設定され、フィールドに含まれるLinkButton コントロールの表示方法が制御されます。

<%@ 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>

注釈

ControlStyle プロパティは、DataControlFieldから派生した型に含まれる Web サーバー コントロールの外観を制御します。

このプロパティは、すべての派生型に影響を与えるわけではありません。 通常、テキスト データを表示し、BoundFieldコントロールのみを含む TextBox コントロールは、ControlStyle状態にある場合にのみ、Edit プロパティの影響を受けます。 ButtonFieldやCheckBoxFieldなどの Web サーバー コントロールは、フィールドに含まれるコントロール オブジェクト インスタンスの特定の構成によっては、ControlStyle プロパティの影響を受ける可能性があります。 たとえば、 ButtonField コントロールは、 LinkButton、 ImageButton、または Button オブジェクトとしてレンダリングできます。 LinkButton コントロールは、指定したfont オブジェクトのStyle属性の影響を受けますが、Button コントロールは影響を受けません。

適用対象

こちらもご覧ください