如何将数据从一种形式的gridview传输到另一种形式的文本框 [英] how to transfer data from one form of gridview to another form of textboxes

查看:63
本文介绍了如何将数据从一种形式的gridview传输到另一种形式的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击btn_emp serachform将打开

span class =code-keyword> void Btn_Emp_Click( object sender,EventArgs e)
{
serachfrom1 sa = new serachfrom1();
sa.ShowDialog();

}







点击gridview中的选择按钮吧在课程控制表格中将数据传输到文本框





 私有  void  Tsb_Select_Click_1(对象发​​件人,EventArgs e)
{
cousecontrol cr = new cousecontrol();
cr.Show();


}

解决方案

有很多方法可以将数据从一个表单传输到第二个表单请告诉我你有windows窗体或asp.net表格吗?

如果你使用asp.net表格那么

你可以使用

server.transfer



您可以通过各种方式在页面之间传递信息,其中一些方式取决于重定向的发生方式。即使源页面与目标页面位于不同的ASP.NET Web应用程序中,或者源页面不是ASP.NET网页,也可以使用以下选项:



使用查询字符串。



从源页面获取HTTP POST信息。



仅当源页面和目标页面位于同一ASP.NET Web应用程序中时,以下选项才可用。



使用会话状态。



在源页面中创建公共属性并访问目标页面中的属性值。



从控件获取目标页面中的控件信息在源页面。





如果您使用的是窗体,那么



使用构造函数

使用对象

使用属性

在表单1中使用委托


写这个代码



<前郎=cs> 使用(Form2 form2 = new Form2())
{
if (form2.ShowDialog()== DialogResult.OK)
{
someControlOnForm1.Text = form2.TheValue;
}
}





并以表格形式2写下此代码

< pre lang =cs> // 创建公共属性以提供值
< span class =code-keyword> public string TheValue
{
get { return someTextBoxOnForm2.Text; }
}


由于这个问题非常受欢迎,我以前的答案往往不太清楚,可能还不够清楚,我决定写一篇提示/技巧文章,详细的代码示例和解释:一次回答的许多问题 - Windows窗体或WPF Windows之间的协作



-SA


coursecontrol form by clicking btn_emp serachform will open

private void Btn_Emp_Click(object sender, EventArgs e)
       {
           serachfrom1 sa = new serachfrom1();
           sa.ShowDialog();

       }




by clicking select button in gridview it trasfer data to textboxes in coursecontrol form


private void Tsb_Select_Click_1(object sender, EventArgs e)
       {
           cousecontrol cr = new cousecontrol();
           cr.Show();


       }

解决方案

There are many way to transfer data from one form to second one Please let me know do you have windows form or asp.net form ?
if you are using asp.net form then
you can use
server.transfer

You can pass information between pages in various ways, some of which depend on how the redirection occurs. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web page:

Use a query string.

Get HTTP POST information from the source page.

The following options are available only when the source and target pages are in the same ASP.NET Web application.

Use session state.

Create public properties in the source page and access the property values in the target page.

Get control information in the target page from controls in the source page.


If You are using windows form then

Using constructor
Using objects
Using properties
Using delegates


in form 1 write this code

using(Form2 form2 = new Form2())
{
  if(form2.ShowDialog() == DialogResult.OK)
  {
    someControlOnForm1.Text = form2.TheValue;
  }
}



and in form form 2 write this code

//Create a public property to serve the value
public string TheValue
{
  get { return someTextBoxOnForm2.Text; }
}


As the question turned out to be very popular, and my previous answers often were not well understood, probably were not clear enough, I decided to write a Tips/Trick article complete with detailed code samples and explanations: Many Questions Answered at Once — Collaboration between Windows Forms or WPF Windows.

—SA


这篇关于如何将数据从一种形式的gridview传输到另一种形式的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆