我这里有个页面类似相册页面
分为两个显示区域a和b;
b的内容是DataList绑定的照片缩略图列表。a接收参数显示的是照片大图,问题是:在查看第二页的某张照片时,分页部分就会回到第一页。这个问题应该怎么解决?以下是处理的源代码,拆分成两个frame的方法忽略。
<webdiyer:aspnetpager id="AspNetPager1" runat="server" onpagechanged="AspNetPager1_PageChanged"
showcustominfosection="Left" width="400px"
CustomInfoHTML="第%CurrentPageIndex%页,共%PageCount%页,%PageSize%条/每页"
PageIndexBoxStyle="width:19px" NumericButtonCount="5"
ShowMoreButtons="False"></webdiyer:aspnetpager> protected void Page_Load(object sender, EventArgs e)
{
Users.checkLogin();//登陆检测
Tools.checkUrl();//是否外部提交
//
//参数处理
//
if (!IsPostBack)
{
if (Request.QueryString["tag"] == "delsuccess")
{
Literal1.Text = "上一张照片已经删除!";
}
else if (Request.QueryString["tag"] == "delfailed")
{
Literal1.Text = "对不起你的照片删除失败!";
}
if (Convert.ToInt64(Request.QueryString["pid"]) > 0)
{
pid = Convert.ToInt64(Request.QueryString["pid"]);
}
else
{
pid = Photos.GetPicID(Session["uid"]);
}
p_path = Photos.GetPicUrl(pid);
//int return_num;
Image1.ImageUrl = p_path;
Image1.Attributes.Add("OnLoad", "javascript:DrawImage(this,360,480)"); pindex = Convert.ToInt32(Request.QueryString["pindex"]);
Button2.Attributes.Add("onclick", "javascript:if(!confirm('你确定要删除该照片吗?')) { return false; }");
SqlParameter[] para = new SqlParameter[1];
para[0] = new SqlParameter("@in_uid", Convert.ToInt64(Session["uid"]));
int totalOrders = (int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_wPhoto_GetNumByUid", para);
AspNetPager1.RecordCount = totalOrders;
bindData();
}
}
void bindData()
{
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
//打开连接
conn.Open();
SqlParameter[] para = new SqlParameter[3];
para[0] = new SqlParameter("@in_uid", 65);
para[1] = new SqlParameter("@startIndex", AspNetPager1.StartRecordIndex);
para[2] = new SqlParameter("@endIndex", AspNetPager1.EndRecordIndex);
DataList1.DataSource = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "sp_wPhoto_Page", para);
//SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sqlexec, null);
//DataList1.DataSource = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text, sqlexec, null),);
DataList1.DataBind();
}
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
bindData();
}
分为两个显示区域a和b;
b的内容是DataList绑定的照片缩略图列表。a接收参数显示的是照片大图,问题是:在查看第二页的某张照片时,分页部分就会回到第一页。这个问题应该怎么解决?以下是处理的源代码,拆分成两个frame的方法忽略。
<webdiyer:aspnetpager id="AspNetPager1" runat="server" onpagechanged="AspNetPager1_PageChanged"
showcustominfosection="Left" width="400px"
CustomInfoHTML="第%CurrentPageIndex%页,共%PageCount%页,%PageSize%条/每页"
PageIndexBoxStyle="width:19px" NumericButtonCount="5"
ShowMoreButtons="False"></webdiyer:aspnetpager> protected void Page_Load(object sender, EventArgs e)
{
Users.checkLogin();//登陆检测
Tools.checkUrl();//是否外部提交
//
//参数处理
//
if (!IsPostBack)
{
if (Request.QueryString["tag"] == "delsuccess")
{
Literal1.Text = "上一张照片已经删除!";
}
else if (Request.QueryString["tag"] == "delfailed")
{
Literal1.Text = "对不起你的照片删除失败!";
}
if (Convert.ToInt64(Request.QueryString["pid"]) > 0)
{
pid = Convert.ToInt64(Request.QueryString["pid"]);
}
else
{
pid = Photos.GetPicID(Session["uid"]);
}
p_path = Photos.GetPicUrl(pid);
//int return_num;
Image1.ImageUrl = p_path;
Image1.Attributes.Add("OnLoad", "javascript:DrawImage(this,360,480)"); pindex = Convert.ToInt32(Request.QueryString["pindex"]);
Button2.Attributes.Add("onclick", "javascript:if(!confirm('你确定要删除该照片吗?')) { return false; }");
SqlParameter[] para = new SqlParameter[1];
para[0] = new SqlParameter("@in_uid", Convert.ToInt64(Session["uid"]));
int totalOrders = (int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_wPhoto_GetNumByUid", para);
AspNetPager1.RecordCount = totalOrders;
bindData();
}
}
void bindData()
{
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
//打开连接
conn.Open();
SqlParameter[] para = new SqlParameter[3];
para[0] = new SqlParameter("@in_uid", 65);
para[1] = new SqlParameter("@startIndex", AspNetPager1.StartRecordIndex);
para[2] = new SqlParameter("@endIndex", AspNetPager1.EndRecordIndex);
DataList1.DataSource = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "sp_wPhoto_Page", para);
//SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sqlexec, null);
//DataList1.DataSource = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text, sqlexec, null),);
DataList1.DataBind();
}
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
bindData();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货