- 爱易网页
-
ASP.NET教程
- 说当前上下文不存在reuqest,该如何解决
日期:2014-05-19 浏览次数:20448 次
说当前上下文不存在reuqest
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// Fpage 的摘要说明
/// </summary>
public class Fpage
{
public string dqy, ygy, syy, xyy;
public PagedDataSource Pds;
public Fpage()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public void fkai(string con_str,string sql_str)
{
SqlConnection Scon = new SqlConnection(con_str);
SqlDataAdapter Sda = new SqlDataAdapter(sql_str, Scon);
DataSet Ds = new DataSet();
Sda.Fill(Ds);
PagedDataSource Pds = new PagedDataSource();
Pds.DataSource = Ds.Tables[0].DefaultView;
Pds.AllowPaging = true;
Pds.PageSize = 5;
int CurPage;
if (Request.QueryString[ "Page "] != null)
CurPage = Convert.ToInt32(Request.QueryString[ "Page "]);
else
CurPage = 1;
Pds.CurrentPageIndex = CurPage - 1;
dqy = "当前页: " + CurPage.ToString();
ygy = "一共: " + Pds.PageCount.ToString();
if (!Pds.IsFirstPage)
syy = Request.AppRelativeCurrentExecutionFilePath + "?Page= " + Convert.ToString(CurPage - 1);
if (!Pds.IsLastPage)
xyy = Request.AppRelativeCurrentExecutionFilePath + "?Page= " + Convert.ToString(CurPage + 1);