关于一段翻页代码,翻页不更新??
第一页正常,点下一页,内容和第一页一样,或者只换了2条后页的内容。搞不明白。。。默认一页显示20条信息,但我点显示方式,选择一页显示80条,可以正常显示
using ASP;
using System;
using System.Data;
using System.Text;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using Web9eat.BLL;
using Web9eat.WebBase;
using Wuqi.Webdiyer;
using System.Configuration;
public class Company_Vip_Default : Page, IRequiresSessionState
{
private string _area = "";
private string _c_model = "";
private string _order = "";
private int _page = 1;
private int _pagesize = 20;
private string _show = "";
protected string _type = "All";
private Ad bAd = new Ad();
private All_Model bAll_Model = new All_Model();
private C_About bC_About = new C_About();
private Hotel bHotel = new Hotel();
protected string CompanyList = "";
protected AspNetPager PageCtrl;
protected string DisplaySettings()
{
StringBuilder result = new StringBuilder();
result.AppendLine("<div id=\"DisplayMode\">显示方式:");
if (((this._show == "") && (this._show != "word")) && (this._show != "pic"))
{
result.Append("<a href=\"" + this.SetLink(this._type, this._pagesize, "", this._order, this._page, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/display_mode_list_act.gif\" title=\"列表方式\" alt=\"列表方式\" />");
result.Append("</a>");
}
else
{
result.Append("<a href=\"" + this.SetLink(this._type, this._pagesize, "", this._order, this._page, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/display_mode_list.gif\" title=\"列表方式\" alt=\"列表方式\" />");
result.Append("</a>");
}
if (this._show == "pic")
{
result.Append("<a href=\"" + this.SetLink(this._type, this._pagesize, "pic", this._order, this._page, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/display_mode_grid_act.gif\" title=\"图片方式\" alt=\"图片方式\" />");
result.Append("</a>");
}
else
{
result.Append("<a href=\"" + this.SetLink(this._type, this._pagesize, "pic", this._order, this._page, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/display_mode_grid.gif\" title=\"图片方式\" alt=\"图片方式\" />");
result.Append("</a>");
}
if (this._show == "word")
{
result.Append("<a href=\"" + this.SetLink(this._type, this._pagesize, "word", this._order, this._page, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/display_mode_text_act.gif\" title=\"纯文字方式\" alt=\"纯文字方式\" />");
result.Append("</a>");
}
else
{
result.Append("<a href=\"" + this.SetLink(this._type, this._pagesize, "word", this._order, this._page, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/display_mode_text.gif\" title=\"纯文字方式\" alt=\"纯文字方式\" >");
result.Append("</a>");
}
result.Append("</div>");
result.AppendLine("<div id=\"ItemAmount\">每页显示数量:");
if ((this._pagesize != 40) && (this._pagesize != 80))
{
result.Append("<a href=\"" + this.SetLink(this._type, 20, this._show, this._order, 1, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/item_amount_20_act.gif\" title=\"每页显示20个商家\" alt=\"每页显示20个商家\" />");
result.Append("</a>");
}
else
{
result.Append("<a href=\"" + this.SetLink(this._type, 20, this._show, this._order, 1, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/item_amount_20.gif\" title=\"每页显示20个商家\" alt=\"每页显示20个商家\" />");
result.Append("</a>");
}
if (this._pagesize == 40)
{
result.Append("<a href=\"" + this.SetLink(this._type, 40, this._show, this._order, 1, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/item_amount_40_act.gif\" title=\"每页显示40个商家\" alt=\"每页显示40个商家\" />");
result.Append("</a>");
}
else
{
result.Append("<a href=\"" + this.SetLink(this._type, 40, this._show, this._order, 1, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/item_amount_40.gif\" title=\"每页显示40个商家\" alt=\"每页显示40个商家\" />");
result.Append("</a>");
}
if (this._pagesize == 80)
{
result.Append("<a href=\"" + this.SetLink(this._type, 80, this._show, this._order, 1, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/item_amount_80_act.gif\" title=\"每页显示80个商家\" alt=\"每页显示80个商家\" />");
result.Append("</a>");
}
else
{
result.Append("<a href=\"" + this.SetLink(this._type, 80, this._show, this._order, 1, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/item_amount_80.gif\" title=\"每页显示80个商家\" alt=\"每页显示80个商家\" />");
result.Append("</a>");
}
result.Append("</div>");
result.Append("<div class=\"QuickPageChanger\" >");
result.Append("" + this.PageCtrl.CurrentPageIndex.ToString()).Append("/").Append(this.PageCtrl.PageCount.ToString() + "");
if (this._page > 1)
{
string link = this.SetLink(this._type, this._pagesize, this._show, this._order, this._page - 1, this._area, this._c_model) + "#c";
result.Append("<a href=\"" + link + "\" ><img src=\"/Images/pre_page_易做图_act.gif\" title=\"翻到上一页\" alt=\"翻到上一页\" /></a>");
}
else
{
result.Append("<img src=\"/Images/pre_page_易做图.gif\" title=\"上一页\" alt=\"上一页\" />");
}
if (this._page >= this.PageCtrl.PageCount)
{
result.Append("<img src=\"/Images/next_page.gif\" title=\"下一页\" alt=\"下一页\" />");
}
else
{
result.Append("<a href=\"" + (this.SetLink(this._type, this._pagesize, this._show, this._order, this._page + 1, this._area, this._c_model) + "#c") + "\" ><img src=\"/Images/next_page_act.gif\" title=\"翻到下一页\" alt=\"翻到下一页\" /></a>");
}
result.Append("</div>");
result.AppendLine("");
return result.ToString();
}
private void GetRequestParm()
{
this._type = (ExRequest.GetQueryString("type") != "") ? ExRequest.GetQueryString("type") : "All";
this._area = ExRequest.GetQueryString("area");
this._c_model = ExRequest.GetQueryString("c_model");
this._pagesize = ExRequest.GetQueryInt("pagesize", 20);
this._show = ExRequest.GetQueryString("show");
this._order = ExRequest.GetQueryString("order");
this._page = ExRequest.GetQueryInt("page", 1);
}
protected void Page_Load(object sender, EventArgs e)
{
string ForThisProvince = ConfigurationManager.AppSettings["ForThisProvince"].ToString();
string ForThisCity = ConfigurationManager.AppSettings["ForThisCity"].ToString();
this.GetRequestParm();
this.Page.Title = "城市商家特约商户 优惠商家";
DefaultMasterPage masterPage = (DefaultMasterPage) this.Page.Master;
masterPage.Keywords = Utils.SetKeyWord(this._area + this._c_model) + Utils.SetKeyWord(this._c_model) + "特约商户," + ForThisCity + "打折,网上订餐";
if (!this.Page.IsPostBack)
{
this.RepeaterDataBind(this._page);
}
}
//放不下了,余下代码见沙发
请专家们帮忙分析下是哪里出了问题。可以对照下我的网页http://www.sj37.com/company/vip/ --------------------编程问答--------------------
private void RepeaterDataBind(int currentPageIndex)--------------------编程问答-------------------- if ((this._pagesize != 40) && (this._pagesize != 80))
{
DataTable dt;
if (this._type.ToLower() == "all")
{
int Sum = this.bC_About.SelectList_byPage("Vip", "", this._area, "", this._c_model, "", "");
this.PageCtrl.RecordCount = Sum;
this.PageCtrl.PageSize = this._pagesize;
dt = this.bC_About.SelectList_byPage(this._pagesize, this._page, "Vip", "", this._area, "", this._c_model, "", "");
this.CompanyList = HtmlWrite.CompanyList(dt, "");
}
else if (this._type.ToLower() == "cancel")
{
dt = this.bAd.SelectComanyList("取消商家");
this.CompanyList = HtmlWrite.CompanyList(dt, "");
}
this.PageCtrl.UrlRewritePattern = this.SetLink(this._type, this._pagesize, this._show, this._order, -1, this._area, this._c_model) + "#c";
this.PageCtrl.EnableUrlRewriting = true;
if (this._page >= this.PageCtrl.PageCount)
{
this.PageCtrl.NextPageText = "<img src=\"/Images/next_page.gif\" />";
}
else
{
this.PageCtrl.NextPageText = "<img src=\"/Images/next_page_act.gif\" />";
}
if (this._page > 1)
{
this.PageCtrl.PrevPageText = "<img src=\"/Images/pre_page_易做图_act.gif\" />";
}
else
{
this.PageCtrl.PrevPageText = "<img src=\"/Images/pre_page_易做图.gif\" />";
}
StringBuilder result = new StringBuilder();
result.Append("<div class=\"CustomInfo\" >");
result.Append("<span class=\"RecordInfo\" >");
result.Append("有<b>").Append(this.PageCtrl.RecordCount.ToString()).Append("</b>个商家满足您的条件");
result.Append("</span>");
result.Append("<span class=\"PageInfo\" >");
result.Append("当前第<b>" + this.PageCtrl.CurrentPageIndex.ToString()).Append("</b>页/共<b>").Append(this.PageCtrl.PageCount.ToString() + "</b>页");
result.Append("</span>");
result.Append("</div>");
this.PageCtrl.CustomInfoHTML = result.ToString();
}
private string SetLink(string type, int pagesize, string show, string order, int page, string area, string c_model)
{
StringBuilder url = new StringBuilder();
StringBuilder parm = new StringBuilder();
url.Append("/Company/Vip/").Append(type).Append(".html");
if (pagesize > 20)
{
parm.Append("&pagesize=").Append(pagesize);
}
if (show != "")
{
parm.Append("&show=").Append(show);
}
if (order != "")
{
parm.Append("&order=").Append(order);
}
if (page > 1)
{
parm.Append("&page=").Append(page);
}
else if (page == -1)
{
parm.Append("&page={0}");
}
if (area != "")
{
parm.Append("&area=").Append(Utils.UrlEncode(area));
}
if (c_model != "")
{
parm.Append("&c_model=").Append(Utils.UrlEncode(c_model));
}
if (parm.ToString() != "")
{
parm.Remove(0, 1);
parm.Insert(0, "?");
}
return url.Append(parm).ToString();
}
public string ShowArea()
{
string link = "";
StringBuilder result = new StringBuilder();
result.AppendLine("<div class=\"Title\" >按地区选择</div>");
DataTable dt = this.bAll_Model.SelectAll_ModelList(10, "70");
result.AppendLine("<ul >");
if (this._area != "")
{
link = this.SetLink(this._type, 20, "", "", 1, "", this._c_model);
result.AppendLine("<li><a href=\"" + link + "\" >全部</a></li>");
}
foreach (DataRow dr in dt.Rows)
{
link = this.SetLink(this._type, 20, "", "", 1, dr["model"].ToString(), this._c_model);
result.AppendLine("<li>");
if (this._area == dr["model"].ToString())
{
result.AppendLine("<a class=\"selected\" href=\"" + link + "\" >" + dr["model"].ToString() + "</a>");
}
else
{
result.AppendLine("<a href=\"" + link + "\" >" + dr["model"].ToString() + "</a>");
}
result.AppendLine("</li>");
}
result.AppendLine("</ul>");
dt.Dispose();
return result.ToString();
}
protected string ShowC_model()
{
string link = "";
StringBuilder result = new StringBuilder();
int count = 0;
result.AppendLine("<div class=\"Title\" >按类型选择</div>");
DataTable dt1 = this.bAll_Model.SelectAll_ModelList(10, "jylx");
foreach (DataRow dr1 in dt1.Rows)
{
DataTable dt2 = this.bAll_Model.SelectAll_ModelList(10, dr1["id"].ToString());
result.AppendLine("<ul style=\"border:0px;\" >");
result.AppendLine("<li><span >" + dr1["model"] + "</span></li>");
foreach (DataRow dr2 in dt2.Rows)
{
link = this.SetLink(this._type, 20, "", "", 1, this._area, dr2["model"].ToString());
count = this.bC_About.GetVipCount_byC_Model(dr2["model"].ToString());
result.AppendLine("<li>");
if (this._c_model == dr2["model"].ToString())
{
result.AppendLine("<a class=\"selected\" href=\"" + link + "\" >" + dr2["model"].ToString() + "[" + count.ToString() + "]</a>");
}
else
{
result.AppendLine("<a href=\"" + link + "\" >" + dr2["model"].ToString() + "[" + count.ToString() + "]</a>");
}
result.AppendLine("</li>");
dt2.Dispose();
}
result.AppendLine("</ul>");
}
dt1.Dispose();
return result.ToString();
}
public string ShowImg(string img)
{
if (img != "")
{
return Utils.GetSmallImg(img, "S");
}
return "/images/SP_0001.gif";
}
protected string ShowPremium(string id, string c_vip, object vip, string c_vipmemo)
{
StringBuilder result = new StringBuilder();
if (c_vip == "1")
{
result.Append("<span class=\"Vip\" onMouseMove=\"showDiv('vipMemo_" + id.ToString() + "',1)\" onMouseOut=\"showDiv('vipMemo_" + id.ToString() + "',0)\" >");
result.Append("<img src=\"/Images/user_vip.gif\" /> ");
if (!string.IsNullOrEmpty(vip.ToString()))
{
result.Append(Convert.ToDecimal(vip).ToString("0.0")).Append("折");
}
result.Append("</span>");
result.Append("<div id=\"vipMemo_" + id.ToString() + "\" class=\"VipMemo\" >");
result.Append(c_vipmemo.ToString());
result.Append("</div>");
}
return result.ToString();
}
protected string ShowTabBar()
{
StringBuilder result = new StringBuilder();
this._type = this._type.ToLower();
result.AppendLine(" <ul class=\"TabBarLevel1\" >");
if (this._type == "all")
{
result.AppendLine(" <li class=\"Selected\" ><a href=\"/Company/Vip/All.html#c\" >所有优惠商家</a></li>");
}
else
{
result.AppendLine(" <li ><a class=\"Selected\" href=\"/Company/Vip/All.html#c\" >所有优惠商家</a></li>");
}
result.AppendLine(" <li><a href=\"/VipCard/\" >在线申请</a></li>");
result.AppendLine(" <li><a href=\"/VipCard/?type=2\" >现场办理</a></li>");
if (this._type == "cancel")
{
result.AppendLine(" <li class=\"Selected\" ><a href=\"/Company/Vip/Cancel.html#c\" >取消商家</a></li>");
}
else
{
result.AppendLine(" <li><a href=\"/Company/Vip/Cancel.html#c\" >取消商家</a></li>");
}
result.AppendLine("<li class=\"Text\" ><div >");
result.AppendLine("<span style=\"color:#FF8A00;font-weight:bold\">城市商家提示</span>");
result.AppendLine("<span><img src=\"/Images/user_vip.gif\" />标志的商家会员享受优惠</span></div>");
result.AppendLine(" </li></ul>");
return result.ToString();
}
protected global_asax ApplicationInstance
{
get
{
return (global_asax) this.Context.ApplicationInstance;
}
}
protected DefaultProfile Profile
{
get
{
return (DefaultProfile) this.Context.Profile;
}
}
}
{
这下面的判断都错了。你自己试试当这个PAGESIZE为20时会进入多少个判断中。
PS:很不喜欢这种后台往前台输入HTML代码的。老式的ASP论坛的写法。改起来要命。 --------------------编程问答-------------------- 楼上的大哥能不能写个简洁点的代码,小弟接触.net时间不久,很是头晕。 --------------------编程问答--------------------
--------------------编程问答-------------------- 肯定有逻辑问题
result.Append("<a href=\"" + this.SetLink(this._type, this._pagesize, this._show, this._order, 1, this._area, this._c_model) + "#c\">");
result.Append("<img src=\"/Images/item_amount_20_act.gif\" title=\"每页显示"+this._pagesize.ToString()+"个商家\" alt=\"每页显示"+this._pagesize.ToString()+"个商家\" />");
result.Append("</a>");
JF --------------------编程问答-------------------- 感谢viewStates的悉心指导,但是我换上你提供的代码后,翻页问题还是存在。第一页换第二页的时候只跳了一家商家,后面的3,4,5,6都和第二页完全一样。 --------------------编程问答-------------------- 汗~~ 代码太长 --------------------编程问答-------------------- 请专家们来帮忙。。 --------------------编程问答-------------------- 这样一般都是逻辑有问题~~
使用sql语句的时候直接用 not in 吧 这样也不用判断
if(page !=20 && page != 40)之类的了 --------------------编程问答-------------------- --------------------编程问答-------------------- 能否明示?请帮个忙,被老板催促。。 --------------------编程问答-------------------- 请求高手帮忙 --------------------编程问答-------------------- 看的我好晕啊你发错地方了吧 --------------------编程问答-------------------- 好长啊!!! --------------------编程问答-------------------- 给楼主个可靠的方式
设断点-F5-F10
补充:.NET技术 , C#