gpt4 book ai didi

c# - 如果 Pages = 1,则隐藏 DataPager

转载 作者:太空狗 更新时间:2023-10-29 17:39:28 25 4
gpt4 key购买 nike

如果只有一页数据,如何隐藏DataPager?

在 DataPager 事件中,我有一个 asp:Button,单击它会获取记录。

有时只有一条记录,如果有一条记录,我需要隐藏寻呼机。

它可以在回发时完成,但我不知道页数的属性是什么。

最佳答案

MSDN 上有一篇博客文章涵盖了这个主题:

How to hide a DataPager control when there is only one page of data

One way of achieving this is to change the visibility of the control on the DataBound event of the ListView control. For example:

protected void ListView1_DataBound(object sender, EventArgs e)
{
DataPager1.Visible = (DataPager1.PageSize < DataPager1.TotalRowCount);
}

In the example above, the DataPager is not inside the ListView control. If you place the DataPager inside the LayoutTemplate, then you have to tweak the code a little bit to find the control inside ListView. For example:

protected void ListView1_DataBound(object sender, EventArgs e)
{
DataPager pager = (DataPager) ListView1.FindControl("DataPager1");
pager.Visible = (pager.PageSize < pager.TotalRowCount);
}

关于c# - 如果 Pages = 1,则隐藏 DataPager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9321757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com