Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于 ListView 控件 DataPager,我正在尝试以编程方式设置PageSize,但从代码隐藏中,我看不到数据页。
尝试这样做:
DataPager1.PageSize = 10
但是“DataPager1”不能从页面后面的代码中访问。
谢谢,亚当
如果您的 DataPager 在 ListViews LayoutTemplate 内,则无法从代码隐藏中直接访问它。
要访问 DataPager,您必须使用 ListViews FindControl 方法。
DataPager pager = YourListViewID.FindControl("DataPager1") as DataPager;
请记住在使用之前检查是否找到了寻呼机对象(不同于 null)。