다음을 통해 공유


PagerSettings.Visible 속성

정의

페이지 매김을 지원하는 컨트롤에 페이징 컨트롤이 표시되는지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool Visible { bool get(); void set(bool value); };
public bool Visible { get; set; }
member this.Visible : bool with get, set
Public Property Visible As Boolean

속성 값

페이저를 표시하려면 true로 설정하고, 그렇지 않으면 false로 설정합니다. 기본값은 true입니다.

예제

다음 코드 예제에 사용 하는 방법을 보여 줍니다.는 Visible 호출기를 숨기려면 속성 경우 행을 GridView 컨트롤이 편집 모드 인지 합니다.


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void CustomerGridView_RowEditing(Object sender, GridViewEditEventArgs e)
  {
    // Hide the pager row.
    CustomerGridView.PagerSettings.Visible = false;
  }

  void CustomerGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
  {
    if (e.CommandName == "Cancel" || e.CommandName == "Update")
    {
      // Show the pager row.
      CustomerGridView.PagerSettings.Visible = true;
    }
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>PagerSetting Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>PagerSetting Example</h3>
                       
        <asp:gridview id="CustomerGridView"
          datasourceid="CustomerDataSource"
          autogeneratecolumns="true"
          datakeynames="CustomerID"  
          allowpaging="true"
          autogenerateeditbutton="true"
          onrowediting="CustomerGridView_RowEditing"
          onrowcommand="CustomerGridView_RowCommand"   
          runat="server">
          
          <pagersettings mode="NextPreviousFirstLast"
            firstpagetext="First"
            lastpagetext="Last"
            nextpagetext="Next"
            previouspagetext="Prev"   
            position="Bottom"/> 
            
        </asp:gridview>
        
        <br/>
        
        <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>
            
        <!-- 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="CustomerDataSource"
          selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
          updatecommand="Update [Customers] Set [CompanyName]=@CompanyName, [Address]=@Address, [City]=@City, [PostalCode]=@PostalCode, [Country]=@Country Where [CustomerID]=@CustomerID" 
          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">
<script runat="server">

  Sub CustomerGridView_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles CustomerGridView.RowEditing

    ' Hide the pager row.
    CustomerGridView.PagerSettings.Visible = False
    
  End Sub

  Sub CustomerGridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles CustomerGridView.RowCommand
  
    If e.CommandName = "Cancel" Or e.CommandName = "Update" Then
    
      ' Show the pager row.
      CustomerGridView.PagerSettings.Visible = True
      
    End If
      
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>PagerSetting Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>PagerSetting Example</h3>
                       
        <asp:gridview id="CustomerGridView"
          datasourceid="CustomerDataSource"
          autogeneratecolumns="true"
          datakeynames="CustomerID"  
          allowpaging="true"
          autogenerateeditbutton="true" 
          runat="server">
          
          <pagersettings mode="NextPreviousFirstLast"
            firstpagetext="First"
            lastpagetext="Last"
            nextpagetext="Next"
            previouspagetext="Prev"   
            position="Bottom"/> 
            
        </asp:gridview>
        
        <br/>
        
        <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>
            
        <!-- 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="CustomerDataSource"
          selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
          updatecommand="Update [Customers] Set [CompanyName]=@CompanyName, [Address]=@Address, [City]=@City, [PostalCode]=@PostalCode, [Country]=@Country Where [CustomerID]=@CustomerID" 
          connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
          runat="server"/>
            
      </form>
  </body>
</html>

설명

사용 된 Visible 페이지 매김을 지 원하는 컨트롤의 페이징 컨트롤 표시 되는지 여부를 지정 하는 속성입니다. 페이징 컨트롤을 숨기려면 다음을 설정 합니다 Visible 속성을 false입니다.

이 속성의 값은 뷰 상태에 저장 됩니다.

적용 대상

추가 정보