看了实例,发现使用url分页的时候只传了一个page的参数,如下
http://localhost:4634/test/Default.aspx?page=2
我想做的是
http://localhost:4634/test/Default.aspx?page=2&shopID=5&showDirection=1

解决方案 »

  1.   

     URL只适宜传递纯粹的参数,其中用于直接间接形成SQL查询语句的部分一定要对其进行Replace("'",   "''")替换,以保证所有SQL   Injection漏洞都被堵住。
      

  2.   

    分页的参数主要在存储过程里面加,下面是我写的一个例子:
    ------------------------------------
    --用途:读取招聘推荐信息(用于分页) 
    --项目名称:
    --说明:
    --时间:wk by 2007-4-27 9:54:43
    ------------------------------------CREATE  procedure SearchBase_GetPageZPInfo_fy
    (
    @ZPDL VarChar(10),
    @CityBh VarChar(10),
    @LinkType VarChar(10),
    @Keyboard VarChar(100),
    @pagesize int,
    @pageindex int,
    @docount bit)
    as
    set nocount on
    declare @PageLowerBound int
    declare @PageUpperBound int
    declare @SQL VarChar(1000)
    declare @wheretj VarChar(1000)
    declare @insstr VarChar(1000)
    set @SQL=''
    set @wheretj=''if (@ZPDL<>'')
    begin
    set @wheretj=@wheretj+' and O.ZPDL='''+ @ZPDL +''''
    endif (@CityBh<>'')
    begin
    set @wheretj=@wheretj+' and O.CityBh='''+ @CityBh +''''
    endif (@LinkType<>'')
    begin
    set @wheretj=@wheretj+' and O.LinkType='''+ @LinkType +''''
    end
    if(@docount=1)
    begin
       set @SQL=@SQL+'SELECT  O.*,t.City FROM ZP_INFO O,ZD_CITY t   where O.CityBh=t.CityBh  ' + @wheretj +' and isdeled = 0  order by O.ZPDL, O.CityBh,O.ScBZ desc,O.LinkTime desc,O.id desc'
       exec (@SQL)
    end
    else
    begin
     set @PageLowerBound=(@pageindex-1)*@pagesize
     set @PageUpperBound=@PageLowerBound+@pagesize
     create table #pageindex(id int identity(1,1) not null,nid int)
     set rowcount @PageUpperBound
     set @insstr='insert into #pageindex(nid) select  O.id from ZP_INFO O,ZD_CITY t  where  O.CityBh=t.CityBh  and  O.isdeled = 0  ' + @wheretj
      exec (@insstr)
     set @SQL=@SQL+'SELECT  O.*,t.City FROM ZP_INFO O,#pageindex p,ZD_CITY t where O.CityBh=t.CityBh  and  O.id=p.nid and p.id>'+  CONVERT(VarChar(10),@PageLowerBound) +'  and p.id<='+ CONVERT(VarChar(10),@PageUpperBound) + @wheretj +' and isdeled = 0   order by O.ZPDL, O.CityBh,O.ScBZ desc,O.LinkTime desc,O.id desc'
     exec (@SQL)
    end
    set nocount off
    GO
      

  3.   

    如果你用URL分页 URL中的参数分页控件不会改动的
    也就是你URL中原来有多少参数 控件给你产生的连接里也有多少参数
    比如:
    原url :http://localhost:4634/test/Default.aspx?shopID=5&showDirection=1
    分页控件的页码2的连接 :http://localhost:4634/test/Default.aspx?page=2&shopID=5&showDirection=1