您现在的位置是:网站首页> 编程资料编程资料

浅谈VS中的DataPager分页_实用技巧_

2023-05-24 374人已围观

简介 浅谈VS中的DataPager分页_实用技巧_

微软的DataPager分页功能很强大,不要设置数据库存储过程,只要添加个DataPager控件,关联下要分页的控件,简单设置就可以有不错的分页效果。当然要有更理想的效果还是要前台和后台处理下。

winform下的DataPager 显示模式:

webForm下的样式由TemplatePagerField,NextPreviousPagerField和NumericPagerField控制

通过设置上面几个控件的配合也可以达到winForm下的效果,这3个控件中最重要的是TemplatePagerField控件。

下面简单看看TemplatePagerField控件可以怎么设置:

复制代码 代码如下:

  <%@ Page language="VB" %>
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

http://www.w3.org/1999/xhtml" >
 
    TemplatePagerField.OnPagerCommand Example   
   
 
 
   

     

TemplatePagerField.OnPagerCommand Example


              DataSourceID="StoresDataSource"
        runat="server">
       
         
           
             
             
           
           
           
         
IDStore Name

        

        
         
           
             
                       
           
             
           
         
       

     

     

              ID="ContactsDataPager"
        PageSize="30"
        PagedControlID="StoresListView">
       
         
           
                              Text="<<" Enabled='<%# Container.StartRowIndex > 0 %>' />
                              Text='<%# (Container.StartRowIndex - Container.PageSize + 1) & " - " & (Container.StartRowIndex) %>'
                Visible='<%# Container.StartRowIndex > 0 %>' />
                              Text='<%# (Container.StartRowIndex + 1) & "-" & (IIf(Container.StartRowIndex + Container.PageSize > Container.TotalRowCount, Container.TotalRowCount, Container.StartRowIndex + Container.PageSize)) %>' />
                              Text='<%# (Container.StartRowIndex + Container.PageSize + 1) & " - " & (IIf(Container.StartRowIndex + Container.PageSize*2 > Container.TotalRowCount, Container.TotalRowCount, Container.StartRowIndex + Container.PageSize*2)) %>'
                Visible='<%# (Container.StartRowIndex + Container.PageSize) < Container.TotalRowCount %>' />
           

         

       

     
    
                  ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
            SelectCommand="SELECT [CustomerID], [Name] FROM Sales.Store ORDER BY [Name]">
     

   

 

-六神源码网