aspnetpage的使用方法

 

I.页面代码

 

 <table class="listtable">

 

     <tr class="thead">

      <td>标题</td>

      <td>时间</td>

     </tr>

     <asp:Repeater ID="SQLDataGrid" runat="server">

            <ItemTemplate>

                <tr 

 

οnmοuseοver="this.style.backgroundColor='#CCCCCC'" 

 

οnmοuseοut="this.style.backgroundColor='#ffffff'">

                    <td><%# Eval("PE_CommonModel.Title")%></td>

                    <td><%# Eval("PE_U_pv.UpDateTime")%></td>

                </tr>

            </ItemTemplate>

        </asp:Repeater>

         <tr>

             <td>

<webdiyer:AspNetPager ID="Pager" runat="server"  

 

NextPageText="Next" PrevPageText="Previous"  

 

 

SubmitButtonText="Go" InvalidPageIndexErrorMessage="page index 

 

must be number!!" 

 

 

PageIndexOutOfRangeErrorMessage="page index can not exceed the 

 

range!!"    

 

 

PageIndexBoxType="TextBox" 

 

 

ShowPageIndexBox="Always" TextBeforePageIndexBox="Go to page"   

 

 

TextAfterPageIndexBox="" ShowCustomInfoSection="Never"

                                                       Font-

 

Underline="False"  ShowDisabledButtons="true"

 

 

HorizontalAlign="Right" Wrap="False" 

 

ShowNavigationToolTip="True" FirstPageText="|<" 

 

LastPageText=">|"  ShowMoreButtons="False">

 

 

</webdiyer:AspNetPager>

</td>

        </tr>

    </table>

 

II.cs

protected void Page_Load(object sender, EventArgs e)

 {

  If(!isPostBack){

  BindData();

}

}

private void BindData(){

tring connstr = "Data Source=127.0.0.1;Initial 

 

Catalog=VedioExp;uid=sa;pwd=123456;";

SqlConnection conn = new SqlConnection(connstr);//实例化连接

string cmd = "select *  FROM PE_CommonModel,PE_U_pv where 

 

PE_CommonModel.GeneralID=PE_U_pv.ID  order by 

 

PE_CommonModel.GeneralID desc";

SqlDataAdapter sda = new SqlDataAdapter(cmd, conn);

DataSet ds = new DataSet();

sda.Fill(ds);

 this.Pager.RecordCount = DS.Tables(0).Rows.Count;

 this.Pager.PageSize = 10;

 PagedDataSource pageDS=New  PagedDataSource();

 pageDS.DataSource = DS.Tables(0).DefaultView;

 pageDS.AllowPaging = True

 pageDS.CurrentPageIndex = Pager.CurrentPageIndex - 1;

 pageDS.PageSize = Pager.PageSize;

 SQLDataGrid.DataSource =  pageDS;

 SQLDataGrid.DataBind();

}

 

III,在Pager_PageChanged事件放入BindData();即可.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值