当前位置:编程学习 > C#/ASP.NET >>

急!!!!ASP.NET中 GridView中 数据源换了,页面不更新,今天要交啊,在线等!

大家帮帮忙!!!

页面上有一个GridView   和一个Btn  ,一开始加载页面时,调用下面的方法,给GV绑定数据源.
这个时候 ,List 有16条数据 .


 private void GridViewDataBind()
        {  
            T_FD_OtherContract2 o = ParamsLoad();//查询参数
            List<T_FD_OtherContract2> list = manage.QueryContract(o);
            this.GridView1.DataSource = list;
            this.GridView1.DataBind();
         }

输入一些查询条件后, 再次调用上面的方法.  List  查询出来是4条记录,但是页面上没有更新.还是一开始的16条数据 ..  为什么啊!???????

急死了, 下午要交模块的.. 大家帮帮忙,   拜谢了.!!!!!! 数据 gridview asp.net --------------------编程问答--------------------    有条件的查询,点了btn后 再次调那个方法,  断点也看了,  List的值也取到了.  页面上就是不更新.  
this.GridView1.DataSource =  null;   this.GridView1.DataBind();  然后再绑定.也还是不行,  怎么办啊,来人啊!!!!!!!!! --------------------编程问答-------------------- 你是用ajax或UpdatePanel

如果用UpdatePanel
查询后要加this.UpdatePanel1.Update(); --------------------编程问答-------------------- 有没有碰到过和我情况是一样的?
--------------------编程问答-------------------- 没有用过.用ajax或UpdatePanel
--------------------编程问答-------------------- 贴一下"一开始加载页面时,调用下面的方法,给GV绑定数据源."这个代码 --------------------编程问答--------------------
 protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CreateTrvInner();
                GridViewDataBind();
            }
        }
--------------------编程问答--------------------
引用 5 楼 silwol 的回复:
贴一下"一开始加载页面时,调用下面的方法,给GV绑定数据源."这个代码
 protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CreateTrvInner();
                GridViewDataBind();
            }
        }
这里 --------------------编程问答-------------------- 你的查询按钮事件在哪里? --------------------编程问答--------------------
引用 8 楼 hdhai9451 的回复:
你的查询按钮事件在哪里?
     protected void QueryBtn_Click(object sender, EventArgs e)
        {
GridViewDataBind();
        }
   这.... --------------------编程问答-------------------- 额,看上去好像是没啥问题,而且你说你都debug进去看到list变了
不懂帮顶 --------------------编程问答-------------------- 清理下解决方案 重新生成试试 --------------------编程问答-------------------- 你做个简单测试,点击查询后:
protected void QueryBtn_Click(object sender, EventArgs e)         


GridViewDataBind();         -->你确保程序时进入到这个事件里面执行了吗?

}
你调试看看?
如果已经进来了,建议你这样改一下
this.GridView1.DataSource = null;             
this.GridView1.DataBind(); 

this.GridView1.DataSource = list;             
this.GridView1.DataBind(); 

我就不相信它不能正确绑定

补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,