Share via


FormView.HorizontalAlign 속성

정의

페이지 내에 있는 FormView 컨트롤의 가로 맞춤을 가져오거나 설정합니다.

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

속성 값

HorizontalAlign

HorizontalAlign 값 중 하나입니다. 기본값은 HorizontalAlign.NotSet입니다.

예제

다음 예제에서는 컨트롤을 페이지 가운데에 지정 하려면 속성을 사용 HorizontalAlign 하는 FormView 방법을 보여 줍니다.


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

설명

HorizontalAlign 속성을 사용하여 페이지 내에서 컨트롤의 가로 맞춤을 FormView 지정할 수 있습니다. 다음 표에는 다양한 가로 맞춤 스타일이 나와 있습니다.

HorizontalAlign 값 Description
HorizontalAlign.NotSet 컨트롤의 가로 맞춤이 FormView 설정되지 않았습니다.
HorizontalAlign.Left FormView 컨트롤이 페이지에서 왼쪽에 맞춰집니다.
HorizontalAlign.Center FormView 컨트롤이 페이지 가운데에 있습니다.
HorizontalAlign.Right FormView 컨트롤이 페이지에 오른쪽 맞춤되어 있습니다.
HorizontalAlign.Justify FormView 컨트롤이 페이지의 왼쪽 여백과 오른쪽 여백 모두에 맞춰집니다.

적용 대상

추가 정보