文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>asp.net updatepanel里gridview更新需要点鼠标两次问题解决

asp.net updatepanel里gridview更新需要点鼠标两次问题解决

时间:2011-02-25  来源:来者自来,去者自去



能够传递正确的页码,但返回的页面数据却不正确。所以应该是代码问题,因为表格数据是通过自定义过程读取,所以每次页面提交时都需要重新获取数据,Gridview不能通过viewstate属性传递其数据源的。

获取数据的代码如:

 private void GetData()
{
localhost.QueryCondition condition = null;
if (txtSearchValue.Value != "")//为空查询全部
{
condition = new localhost.QueryCondition
{
FieldName = slctSearchFields.Value,
FieldOper = slctCondition.Value,
FieldValue = txtSearchValue.Value
};
}

localhost.CominfoTemplateService1 service = new localhost.CominfoTemplateService1();
gridInfo.DataSource = service.SearchComsByUserName(Context.User.Identity.Name, condition);
gridInfo.DataBind();
}
而在表格分页代码是这样的。
protected void gridInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GetData();
   gridInfo.PageIndex = e.NewPageIndex;
}
跟踪代码发现在grid的databind后,就会触发rowdata_bind事件,会填充数据,而此时表格的页码还没有发生变化,调用两个语句的顺序为:
gridInfo.PageIndex = e.NewPageIndex;
GetData();
问题解决。

相关阅读 更多 +
排行榜 更多 +
车轮战争

车轮战争

赛车竞速 下载
汽车毁灭赛车

汽车毁灭赛车

赛车竞速 下载
城市追风少年

城市追风少年

赛车竞速 下载