盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

ASP.NET结合存储过程写的通用搜索分页程序

时间:2024/12/29作者:未知来源:盾怪网教程人气:

[摘要]<asp:HyperLink id="HLEndPage" Text="尾页" runat="server"/></sp...
<asp:HyperLink id="HLEndPage" Text="尾页" runat="server"/></span><br>
   
        <asp:Repeater id=Repeater runat="server">

            <HeaderTemplate>

      <table width="583" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#000000"><table width="100%" border="0" cellpadding="4" cellspacing="1" class="TP10_5">
              <tr bgcolor="#999999">
                <td align="center"> <strong><font color="#FFFFFF">订单号</font></strong></td>
                <td align="center"> <strong><font color="#FFFFFF">服务项目</font></strong></td>
                <td align="center"> <strong><font color="#FFFFFF">预订日期</font></strong></td>
                <td align="center"> <strong><font color="#FFFFFF">操作人员</font></strong></td>
                <td align="center"> <strong><font color="#FFFFFF">分配状态</font></strong></td>
                <td> <div align="center"></div></td>
              </tr>
            </HeaderTemplate>

            <ItemTemplate>

              <tr align="center" bgcolor="#FFFFFF" class="small" onMouseOver='this.style.background="#CCCCCC"' onMouseOut='this.style.background="#FFFFFF"'>
                <td><%# DataBinder.Eval(Container.DataItem, "offerid") %></td>
                <td><%# DataBinder.Eval(Container.DataItem, "type") %></td>
                <td><%# DataBinder.Eval(Container.DataItem, "offertime") %></td>
                <td> </td>
                <td> </td>
                <td><a href="javascript:void(window.open('info.asp?id=<%# DataBinder.Eval(Container.DataItem, "offerid") %>','订单分配','height=600,width=1000'))">订单详情</a></td>
              </tr>

            </ItemTemplate>

            <FooterTemplate>

            </table></td>
        </tr>
      </table>

            </FooterTemplate>

        </asp:Repeater>

    </form>
</body>
</html>

--------------------------------------------------------------------------------


up_GetTopicList.sql

--------------------------------------------------------------------------------

CREATE proc up_GetTopicList
       @a_TableList Varchar(200),
       @a_TableName Varchar(30),
       @a_SelectWhere Varchar(500),
       @a_SelectOrderId Varchar(20),
       @a_SelectOrder Varchar(50),
       @a_intPageNo int,
       @a_intPageSize int,
       @RecordCount int OUTPUT
as
   /*定义局部变量*/
   declare @intBeginID         int
   declare @intEndID           int
   declare @intRootRecordCount int
   declare @intRowCount        int
   declare @TmpSelect          NVarchar(600)
   /*关闭计数*/
   set nocount on
  
   /*求总共根贴数*/

   select @TmpSelect = 'set nocount on;select @SPintRootRecordCount = count(*) from '+@a_TableName+' '+@a_SelectWhere
   execute sp_executesql
             @TmpSelect,
             N'@SPintRootRecordCount int OUTPUT',
             @SPintRootRecordCount=@intRootRecordCount OUTPUT

select @RecordCount = @intRootRecordCount

   if (@intRootRecordCount = 0)    --如果没有贴子,则返回零
       return 0
      
   /*判断页数是否正确*/
   if (@a_intPageNo - 1) * @a_intPageSize > @intRootRecordCount
      return (-1)

   /*求开始rootID*/
   set @intRowCount = (@a_intPageNo - 1) * @a_intPageSize + 1
   /*限制条数*/

   select @TmpSelect = 'set nocount on;set rowcount @SPintRowCount;select @SPintBeginID = '+@a_SelectOrderId+' from '+@a_TableName+' '+@a_SelectWhere+' '+@a_SelectOrder
   execute sp_executesql
             @TmpSelect,
             N'@SPintRowCount int,@SPintBeginID int OUTPUT',
             @SPintRowCount=@intRowCount,@SPintBeginID=@intBeginID OUTPUT


   /*结束rootID*/
   set @intRowCount = @a_intPageNo * @a_intPageSize
   /*限制条数*/

   select @TmpSelect = 'set nocount on;set rowcount @SPintRowCount;select @SPintEndID = '+@a_SelectOrderId+' from '+@a_TableName+' '+@a_SelectWhere+' '+@a_SelectOrder
   execute sp_executesql
             @TmpSelect,
             N'@SPintRowCount int,@SPintEndID int OUTPUT',
             @SPintRowCount=@intRowCount,@SPintEndID=@intEndID OUTPUT


if @a_SelectWhere='' or @a_SelectWhere IS NULL
   select @TmpSelect = 'set nocount off;set rowcount 0;select '+@a_TableList+' from '+@a_TableName+' where '+@a_SelectOrderId+' between '
else
   select @TmpSelect = 'set nocount off;set rowcount 0;select '+@a_TableList+' from '+@a_TableName+' '+@a_SelectWhere+' and '+@a_SelectOrderId+' between '

if @intEndID > @intBeginID
   select @TmpSelect = @TmpSelect+'@SPintBeginID and @SPintEndID'+' '+@a_SelectOrder
else
   select @TmpSelect = @TmpSelect+'@SPintEndID and @SPintBeginID'+' '+@a_SelectOrder

   execute sp_executesql
             @TmpSelect,
             N'@SPintEndID int,@SPintBeginID int',
             @SPintEndID=@intEndID,@SPintBeginID=@intBeginID

   return(@@rowcount)
   --select @@rowcount
GO



关键词:ASP.NET结合存储过程写的通用搜索分页程序




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版