PagerSettings.Visible 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示是否在支持分页的控件中显示分页控件。
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
。
示例
下面的代码示例演示如何在控件处于编辑模式时GridView使用Visible属性隐藏寻呼行。
<%@ 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
。
此属性的值存储在视图状态中。