简体   繁体   English

当按钮单击更新数据时,GridView将刷新

[英]GridView to refresh when button click updates data

I have a button click event on a page which ultimate updates a table using: 我在页面上有一个按钮点击事件,最终使用以下内容更新表:

protected void Button2_Click(object sender, EventArgs e)
{
    this.AccessDataSource6.Insert();
}

A GridView bound to a different AccessDataSource, displays data that is updated by the Insert. 绑定到不同AccessDataSource的GridView显示由Insert更新的数据。

What do I need to include in Button2_Click for the GridView to be refreshed? 我需要在Button2_Click中包含什么才能刷新GridView?

GridView.DataBind方法将清除并重新填充网格视图(假设数据源已设置 - 请参阅示例链接)。

On your click event after you insert you should called the GridView.DataBind() method to rebind the data... 在插入后的click事件中,应该调用GridView.DataBind()方法来重新绑定数据...

protected void Button2_Click(object sender, EventArgs e)
{
    this.AccessDataSource6.Insert();
    this.gridView1.DataBind();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM