Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个文本框和按钮。单击按钮时,在文本框中输入的数据存储在数据表中,并且此数据表绑定到网格视图。每当我输入新数据并单击按钮时,先前输入的数据都不会显示在 gridview 中。
如何在每次单击按钮时将数据保留在数据表中?
Call the method to get data in gridview again.
protected void Button1Click(object sender, EventArgs e) { GridView1.DataSource = data; GridView1.DataBind(); }
只需调用gridView.DataBind()即可刷新数据。如果您的添加导致回发,那么您需要确保在页面加载后执行此操作。
gridView.DataBind()