[英]refresh form1 gridview from form2 after inserting the rows
I have small issue, I have datagridview in form1 to which I insert data from form2 using SQL commands, but after button click which includes INSERT command the newly inserted value doesn't appear in form1's datagridview. 我有一个小问题,我在form1中有datagridview,可以使用SQL命令从form2中插入数据,但是单击包含INSERT命令的按钮后,新插入的值不会出现在form1的datagridview中。 Is there any way to solve this ?
有什么办法解决这个问题?
ftry this 炒这个
Form1 frm = new Form1();
frm.methodwhereyoubindgrid();
but the method must be public in the form1 但该方法必须以以下形式公开:
您可以使用
GridView1.DataBind();
Just Rebind the data to the girdview after every insert. 只需在每次插入后将数据重新绑定到girdview。
gridview.DataSource=new Datasource;
gridview.DataBind();
Simply call the GridView Bind Again at Button Click 只需调用GridView,再次在单击按钮时绑定
inside button1_click
在
button1_click
内部
Grid1_Databind();
Rebind the data to the gridview
after every insert. 每次插入后,将数据重新绑定到
gridview
。
gridview1.DataSource = new Datasource;
gridview1.DataBind();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.