一个页面有3个栏目,没个栏目都有一个AspNetPager,逐步调试,每点一次分页,后台都执行3次绑定,求达人帮忙优化一下。

z8129858 2010-11-01 02:44:51
下面是绑定方法和事件
public void bind_default()
{
if (!string.IsNullOrEmpty(Request.QueryString["year"]))
{
if (Request.QueryString["year"].ToString().Equals("2010"))
{
AspNetPager1.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
AspNetPager2.CurrentPageIndex = 1;
AspNetPager3.CurrentPageIndex = 1;
}
else if (Request.QueryString["year"].ToString().Equals("2009"))
{
AspNetPager1.CurrentPageIndex = 1;
AspNetPager2.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
AspNetPager3.CurrentPageIndex = 1;
}
else if (Request.QueryString["year"].ToString().Equals("2008"))
{
AspNetPager1.CurrentPageIndex = 1;
AspNetPager2.CurrentPageIndex = 1;
AspNetPager3.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
}
string tablelist = " sell_2010 ";
string filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
string conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager1.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList1.DataSource = DbAccess.GetPageDataSet(AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList1.DataBind();


tablelist = " sell_2009 ";
filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager2.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList2.DataSource = DbAccess.GetPageDataSet(AspNetPager2.CurrentPageIndex, this.AspNetPager2.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList2.DataBind();

tablelist = " sell_2008 ";
filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager3.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList3.DataSource = DbAccess.GetPageDataSet(AspNetPager3.CurrentPageIndex, this.AspNetPager3.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList3.DataBind();

}
else
{
string tablelist = " sell_2010 ";
string filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
string conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager1.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList1.DataSource = DbAccess.GetPageDataSet(AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList1.DataBind();


tablelist = " sell_2009 ";
filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager2.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList2.DataSource = DbAccess.GetPageDataSet(AspNetPager2.CurrentPageIndex, this.AspNetPager2.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList2.DataBind();

tablelist = " sell_2008 ";
filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager3.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList3.DataSource = DbAccess.GetPageDataSet(AspNetPager3.CurrentPageIndex, this.AspNetPager3.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList3.DataBind();
}
}


protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
this.AspNetPager1.EnableUrlRewriting = true;
this.AspNetPager1.UrlRewritePattern = "show_sell.aspx?year=2010&page={0}";
this.AspNetPager2.EnableUrlRewriting = true;
this.AspNetPager2.UrlRewritePattern = "show_sell.aspx?year=2009&page={0}";
this.AspNetPager3.EnableUrlRewriting = true;
this.AspNetPager3.UrlRewritePattern = "show_sell.aspx?year=2008&page={0}";
this.bind_default();
}
...全文
166 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
z8129858 2010-11-02
  • 打赏
  • 举报
回复
谢谢 opai72731cl
popai72731cl 2010-11-01
  • 打赏
  • 举报
回复
具体说,在每个栏目外加一个updatepanel,当提交时,
每次只更新一个栏目,而不是整个页面更新。
popai72731cl 2010-11-01
  • 打赏
  • 举报
回复
使用Ajax异步分页,性能会大幅提高。
机器人 2010-11-01
  • 打赏
  • 举报
回复
方法1是减少了2次DB查询。
机器人 2010-11-01
  • 打赏
  • 举报
回复
因为页面不知道是哪个List要重新绑定,所以每次提交每个List都会绑定。
解决办法,是把3个栏目当前的绑定数据存放到ViewState里,再定一个Flag,指定要重新绑定哪一个List。
其他不绑定的List的数据从ViewState里取回。代价就是客户端的页面里存了很多东西!

再或者,你把3个栏目分到3个aspx里,主画面用iframe来显示。这样谁提交刷新谁,相互不影响。
z8129858 2010-11-01
  • 打赏
  • 举报
回复
达人,你在哪里
z8129858 2010-11-01
  • 打赏
  • 举报
回复
1楼朋友,你发的有什么改动么?
z8129858 2010-11-01
  • 打赏
  • 举报
回复
由于绑定的内容数据量挺大,所以现在的方法执行一次很慢,AspNetPager没用过几次,请达人们帮忙看看

自己顶
吴青峰 2010-11-01
  • 打赏
  • 举报
回复
改这个试试:
public void bind_default()
{
if (!string.IsNullOrEmpty(Request.QueryString["year"]))
{
if (Request.QueryString["year"].ToString().Equals("2010"))
{
AspNetPager1.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
AspNetPager2.CurrentPageIndex = 1;
AspNetPager3.CurrentPageIndex = 1;
}
else if (Request.QueryString["year"].ToString().Equals("2009"))
{
AspNetPager1.CurrentPageIndex = 1;
AspNetPager2.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
AspNetPager3.CurrentPageIndex = 1;
}
else if (Request.QueryString["year"].ToString().Equals("2008"))
{
AspNetPager1.CurrentPageIndex = 1;
AspNetPager2.CurrentPageIndex = 1;
AspNetPager3.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
}
string tablelist = " sell_2010 ";
string filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
string conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager1.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList1.DataSource = DbAccess.GetPageDataSet(AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList1.DataBind();


tablelist = " sell_2009 ";
filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager2.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList2.DataSource = DbAccess.GetPageDataSet(AspNetPager2.CurrentPageIndex, this.AspNetPager2.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList2.DataBind();

tablelist = " sell_2008 ";
filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager3.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList3.DataSource = DbAccess.GetPageDataSet(AspNetPager3.CurrentPageIndex, this.AspNetPager3.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList3.DataBind();

}
else
{
string tablelist = " sell_2010 ";
string filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
string conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager1.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList1.DataSource = DbAccess.GetPageDataSet(AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList1.DataBind();


tablelist = " sell_2009 ";
filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager2.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList2.DataSource = DbAccess.GetPageDataSet(AspNetPager2.CurrentPageIndex, this.AspNetPager2.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList2.DataBind();

tablelist = " sell_2008 ";
filed = " id,uid,product,addtime,updatetime,productimage,sm_productimage ";
conditions = " and uid=" + Convert.ToInt32((Str.StringFilter(Session["uid"].ToString()))) + " ";
this.AspNetPager3.RecordCount = DbAccess.ItemsCount("id", tablelist, conditions);
DataList3.DataSource = DbAccess.GetPageDataSet(AspNetPager3.CurrentPageIndex, this.AspNetPager3.PageSize, "id", filed, tablelist, conditions, "order by addtime desc,id desc").Tables[0];
DataList3.DataBind();
}
}


protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
this.AspNetPager1.EnableUrlRewriting = true;
this.AspNetPager1.UrlRewritePattern = "show_sell.aspx?year=2010&page={0}";
this.AspNetPager2.EnableUrlRewriting = true;
this.AspNetPager2.UrlRewritePattern = "show_sell.aspx?year=2009&page={0}";
this.AspNetPager3.EnableUrlRewriting = true;
this.AspNetPager3.UrlRewritePattern = "show_sell.aspx?year=2008&page={0}";
this.bind_default();
}
内容概要:本文针对无刷直流电机驱动的电子机械制动(EMB)执行器,建立了考虑Stribeck摩擦特性的非线性耦合动力学模型,并在Simulink环境中完成了系统级仿真分析。研究综合集成了电机动力学、齿轮传动机构与制动执行机构的动力学特性,构建了高保真的机电一体化系统模型。重点引入Stribeck摩擦模型以精确描述低速工况下执行器内部存在的静摩擦、粘滞摩擦与库仑摩擦之间的过渡行为,有效提升了系统在启停、反向运动等瞬态过程中的动态响应仿真精度。通过多工况仿真验证了模型的有效性,能够准确反映摩擦引起的爬行、滞后与定位误差等非线性现象,为EMB系统的高性能控制算法设计(如摩擦补偿、滑模控制)与结构优化提供了高可信度的仿真平台。; 适合人群:从事汽车电子制动系统、电机驱动控制、机电系统建模与仿真研究的研究生、科研人员及工程技术人员,需具备扎实的机械动力学、自动控制理论基础和MATLAB/Simulink仿真能力。; 使用场景及目标:①用于高精度电子机械制动系统的设计验证与性能预测;②为消除摩擦非线性影响的先进控制策略(如自适应控制、智能控制)提供精确的被控对象模型;③深入探究Stribeck摩擦等非线性因素对系统动态性能(如响应延迟、稳态误差)的作用机理; 阅读建议:读者应结合提供的Simulink模型文件,深入剖析Stribeck摩擦模块的数学实现与参数辨识方法,建议通过改变输入指令(如阶跃、正弦)和负载条件进行对比仿真,以直观理解非线性摩擦对系统动态特性的影响。

62,271

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧