::
::
::
::
::
C#代码
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
***************************************************************************************************************
2
protected void Page_Load(object sender, EventArgs e)
3![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
4
string id = "1000";
5
if (Request.QueryString["id"] != null) id = Request.QueryString["id"].ToString();
6![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
string[] str = BuildPages.GetUrlNavigation(id, "doo_sca", "sca_name", "doo_sca_id", "");
8
Response.Write("上一个:" + str[0].ToString() + " 下一个:" + str[1].ToString());
9
}
10![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
***************************************************************************************************************
12![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//// <summary>
14
/// 还回上一条,下一条
15
/// </summary>
16
/// <param name="CurrentId">当前ID值</param>
17
/// <param name="tblName">表名</param>
18
/// <param name="fldName">主键名</param>
19
/// <param name="titFldName">显示标题</param>
20
/// <param name="strWhere">条件</param>
21
/// <returns></returns>
22
public static string[] GetUrlNavigation(string CurrentId, string tblName,string titFldName, string fldName, string strWhere)
23![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
24
if (StringHelper.IsNumber(CurrentId))
25![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
26![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
SqlParameter[] parameters =
{
27
new SqlParameter("@CurrentId", SqlDbType.VarChar,255),
28
new SqlParameter("@tblName", SqlDbType.VarChar,1000),
29
new SqlParameter("@titFldName", SqlDbType.VarChar,255),
30
new SqlParameter("@fldName", SqlDbType.VarChar,255),
31
new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
32
new SqlParameter("@PID", SqlDbType.VarChar,255),
33
new SqlParameter("@PTit", SqlDbType.VarChar,255),
34
new SqlParameter("@NID", SqlDbType.VarChar,255),
35
new SqlParameter("@NTit", SqlDbType.VarChar,255)};
36
parameters[0].Value = CurrentId;
37
parameters[1].Value = tblName;
38
parameters[2].Value = titFldName;
39
parameters[3].Value = fldName;
40
parameters[4].Value = strWhere;
41
parameters[5].Direction = ParameterDirection.Output;
42
parameters[6].Direction = ParameterDirection.Output;
43
parameters[7].Direction = ParameterDirection.Output;
44
parameters[8].Direction = ParameterDirection.Output;
45
DbHelperSQL.RunProcedure("UP_Navigation", parameters);
46
string strArr1 = "没有了";
47
string strArr2 = "没有了";
48
string PageUrl = HttpContext.Current.Request.FilePath;
49![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
string[] strA =
{ "id" };
50
string UrlParm = RetrunQueryString(strA);//重构URL参数
51
if (!string.IsNullOrEmpty(parameters[5].Value.ToString()))
52![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
53![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
54
strArr1 = "<a href=\""+PageUrl+"?id="+parameters[5].Value.ToString()+UrlParm+"\" >"+parameters[6].Value.ToString()+"</a>";
55
}
56
if (!string.IsNullOrEmpty(parameters[7].Value.ToString()))
57![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
58![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
59
strArr2 = "<a href=\"" + PageUrl + "?id=" + parameters[7].Value.ToString() + UrlParm + "\" >" + parameters[8].Value.ToString() + "</a>";
60
}
61![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
return new string[2]
{ strArr1, strArr2};
62
}
63
else
64![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
65
return null;
66
}
67
}
68![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
69
*************************************************************************************************************
70![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
存储过程:
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[UP_Navigation]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
6
drop procedure [dbo].[UP_Navigation]
7
GO
8
Create PROCEDURE UP_Navigation
9
@CurrentID varchar(255),
10
@tblName varchar(500),--表名
11
@titFldName varchar(255),--显示的字段
12
@fldName varchar(255),--主键
13
@strWhere varchar(1000) = '',--条件
14
@PID VARCHAR(255) out,
15
@PTit VARCHAR(255) out,
16
@NID VARCHAR(255) out,
17
@NTit VARCHAR(255) out
18
AS
19
SET NOCOUNT ON
20
DECLARE @strPSQL nvarchar(4000)
21
DECLARE @strNSQL nvarchar(4000)
22
--SELECT @PID=ISNULL(MIN(@fldName),0) FROM @tblName WHERE @CurrentID<@fldName --上一编ID
23
SET @strPSQL='SELECT @PID='+@fldName+',@PTit='+@titFldName+' FROM '+@tblName+' WHERE '+@fldName+'=(SELECT MIN('+@fldName+') FROM '+@tblName+' WHERE ('+@CurrentID+' < '+@fldName+')'
24
IF(@strWhere !='')
25
BEGIN
26
SET @strPSQL=@strPSQL +' AND (' +@strWhere+')'
27
END
28
SET @strPSQL=@strPSQL+')'
29
EXEC sp_executesql @strPSQL,N'@PID VARCHAR(255) output,@PTit VARCHAR(255) output',@PID output,@PTit output
30
--SELECT @NID=ISNULL(MAX(@fldName),0) FROM @tblName WHERE @CurrentID>@fldName --下一编ID
31
SET @strNSQL='SELECT @NID='+@fldName+',@NTit='+@titFldName+' FROM '+@tblName+' WHERE '+@fldName+'=(SELECT MAX('+@fldName+') FROM '+@tblName+' WHERE ('+@CurrentID+' > '+@fldName+')'
32
IF(@strWhere !='')
33
BEGIN
34
SET @strNSQL=@strNSQL +' AND (' +@strWhere+')'
35
END
36
SET @strNSQL=@strNSQL+')'
37
EXEC sp_executesql @strNSQL,N'@NID VARCHAR(255) output,@NTit VARCHAR(255) output',@NID output,@NTit output
38
SET NOCOUNT OFF
39
GO
40![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
DECLARE @P varchar(255)
42
DECLARE @N varchar(255)
43
DECLARE @Pt varchar(255)
44
DECLARE @Nt varchar(255)
45
EXEC UP_Navigation 5000,'doo_sca','sca_name','doo_sca_id','city_area=592 ',@p output,@n output,@pt output,@nt output
46
SELECT @P,@N,@Pt,@Nt
posted on
2009-02-19 04:08
睿达团队
阅读(
728)
评论()
编辑
收藏
举报