zoukankan      html  css  js  c++  java
  • 取GridView的PagerTemplate里面的控件ID

    今天在做一个Web项目的时候用到了GridView分页,但是GridView自带的分页实在是...,所以找了一个AspNetPager来用一下,于是在GridView的"PagerTemplate"模板里面增加了一个AspNetPager,如下代码:

    <PagerTemplate>                    
                        <WebPage:AspNetPager AspNetPager ID="AspNetPager1" runat="server" ShowBoxThreshold="5" 
                            ShowPageIndexBox="Auto" CenterCurrentPageButton="True" 
                            PageSize="20"                         
                            onpagechanging="AspNetPager1_PageChanging" AlwaysShow="True">
                        </WebPage:AspNetPager>                    
                    </PagerTemplate>

    后台代码里面我需要来获取这个AspNetPager控件,我要设置它的RecordCount值,但是无论怎么样都找不到这个AspNetPager,直接FindControl("AspNetPager1")根本没用,每次DeBug的时候总是Null,后来找了很多资料才发现通过以下方式在可以取值:

    AspNetPager aspnetpage = (AspNetPager)this.dgvUserList.BottomPagerRow.Cells[0].FindControl("AspNetPager1") as AspNetPager;        
            aspnetpage.RecordCount = Dt_UserList.Rows.Count;

    记录一下,避免以后遇见相同的情况又不明白是怎么回事。

查看全文
  • 相关阅读:
    [iOS]Xcode+GitHub远程代码托管(GIT, SVN)
    [iOS]Xcode处理过时方法的警告
    [iOS]@synthesize和@dynamic关键字
    [iOS]图片高清度太高, 导致内存过大Crash
    [软件]Xcode查找系统framework所在路径
    [软件]在浏览器里添加MarkDown Here(插件)
    [PHP]利用XAMPP搭建本地服务器, 然后利用iOS客户端上传数据到本地服务器中(四. iOS端代码实现)
    ios -Unity3D的EasyAR集成到已经有项目中。
    iOS创建安全的单例
    阿里云轻量应用服务器 配置mysql详解(转载)
  • 原文地址:https://www.cnblogs.com/allen0118/p/2747796.html
  • Copyright © 2011-2022 走看看