FormView.HorizontalAlign Eigenschaft

Definition

Ruft die horizontale Ausrichtung eines FormView-Steuerelements auf der Seite ab bzw. legt die Ausrichtung fest.

public:
 virtual property System::Web::UI::WebControls::HorizontalAlign HorizontalAlign { System::Web::UI::WebControls::HorizontalAlign get(); void set(System::Web::UI::WebControls::HorizontalAlign value); };
public virtual System.Web.UI.WebControls.HorizontalAlign HorizontalAlign { get; set; }
member this.HorizontalAlign : System.Web.UI.WebControls.HorizontalAlign with get, set
Public Overridable Property HorizontalAlign As HorizontalAlign

Eigenschaftswert

HorizontalAlign

Einer der HorizontalAlign-Werte. Der Standardwert ist HorizontalAlign.NotSet.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie Sie die HorizontalAlign Eigenschaft verwenden, um anzugeben, dass ein FormView Steuerelement auf der Seite zentriert werden soll.


<%@ 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>FormView HorizontalAlign Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView HorizontalAlign Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        horizontalalign="Center"
        gridlines="Both"  
        runat="server">
        
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>
        
        </itemtemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </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>FormView HorizontalAlign Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView HorizontalAlign Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        horizontalalign="Center"
        gridlines="Both"  
        runat="server">
        
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>
        
        </itemtemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

Hinweise

Verwenden Sie die HorizontalAlign Eigenschaft, um die horizontale Ausrichtung eines FormView Steuerelements auf der Seite anzugeben. In der folgenden Tabelle sind die verschiedenen horizontalen Ausrichtungsformatvorlagen aufgeführt.

HorizontalAlign-Wert BESCHREIBUNG
HorizontalAlign.NotSet Die horizontale Ausrichtung des FormView Steuerelements wurde nicht festgelegt.
HorizontalAlign.Left Das FormView Steuerelement ist linksbündig auf der Seite ausgerichtet.
HorizontalAlign.Center Das FormView Steuerelement wird auf der Seite zentriert.
HorizontalAlign.Right Das FormView Steuerelement ist rechtsbündig auf der Seite ausgerichtet.
HorizontalAlign.Justify Das FormView Steuerelement wird sowohl mit den linken als auch den rechten Rand der Seite ausgerichtet.

Gilt für

Siehe auch