asp.net 上一条和下一条记录的显示
这里我用的是input标签跳转页面的:
前台aspx页面中:
<input class="btn" id="btnSetForm" type="button" value="设置考核关系" onclick="location.href ='../CompanyAdmin/AppraiseRelation.aspx?eid=<%=EmployeeID%>';"/> //当前记录
<input class="btn" id="Button3" type="button" value="为上个人设置考核表" onclick="location.href ='../CompanyAdmin/SetForm.aspx?eid=<%=EmployeeID_0%>';"/> //当前的前一条记录
<input class="btn" id="Button1" type="button" value="为下个人设置考核表" onclick="location.href ='../CompanyAdmin/SetForm.aspx?eid=<%=EmployeeID_1%>';"/> //当前的后一条记录
其中EmployeeID_0 ,EmployeeID, EmployeeID_1分别是上一条、当前、下一条记录的ID
sql语句:@ID为当前EmployeeID
上一条:select top 1 ID,RealName from OPA_Employee where EmployeeID<@EmployeeID order by ENumber desc //降序,取相邻第一个
下一条:select top 1 ID,RealName from OPA_Employee where EmployeeID>@EmployeeID order by ENumber asc //升序,取相邻第一个(默认为升序)
后台aspx.cs页面中调用:
EmployeeID_0=user.getBefore(EmployeeID).ID;
EmployeeID_1=user.getNext(EmployeeID).ID;