如何通过编码更新另一页中的gridview [英] how to update gridview in another page through coding
本文介绍了如何通过编码更新另一页中的gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生您好,
我有两种形式,一种是我输入emp数据,然后将它们显示在gridview的另一页上.我想在该页面上进行编辑,更新和删除.但是我该怎么做.
Hello sir,
I have two forms in one form i have entered the emp data and showed them on another Page in gridview .I want edit ,update,and delete on that page .But how i have to do this .
推荐答案
vashikhan,
首先,您必须在form2中创建一个重载的构造函数,并在form1中创建一个全局对象,您已经存在的默认构造函数为:
Hi vashikhan,
first you must create an overloaded constructor in form2 and a global object of form1 , your already existing default constructor is :
public Form2()
{
InitializeComponent();
}
全局对象和重载的构造函数代码将是:
The global object and the overloaded constructor code will be :
public static Form1 Frm1 = new Form1();
public Form2(Form1 form)
{
InitializeComponent();
Frm1 = form;
}
现在,您可以在form1的修饰符中将datagridview设置为public.
然后在点击添加按钮事件中,您将插入以下代码以打开form2:
Now you can set your datagridview in form1 ''s modifier to public .
Then in the click add button event you will insert this code for opening form2 :
Form2 Frm2 =new Form2(this);
Frm2.show();
希望对您有帮助,
祝你好运
:)
I Hope this help you ,
Good luck
:)
这篇关于如何通过编码更新另一页中的gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文