如何将gridview中的值发送到另一个gridview [英] How can I send values from gridview to another gridview

查看:79
本文介绍了如何将gridview中的值发送到另一个gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个gridview(带两个发送按钮),列号相同,文本框带一个按钮,我写入文本框一些ID,当我点击这个按钮时,第一个gridview执行sp_xyz并从那里获取值,在第一个gridview获取值之后我点击第一个gridview发送按钮发送值第二个gridview但我想执行sp_123但是我想不出来,sp_xyz已经在sp_123中声明我不知道有sql部分的任何问题。我想学习如何执行sp_123从第一个gridview获取值以发送第二个gridview。



我尝试过:



我一直试图通过数据绑定,SetOutData获取价值,我列出了对象而且我得到了值但我无法在第二个gridview中显示,我在某处丢失了数据。


I have two gridview (with two "send" button) with same column names and textbox with a button, I write to textbox some ID and when I click this button 1st gridview execute "sp_xyz" and takes value from there, after 1st gridview get value I am clicking 1st gridview send button to send values 2nd gridview but I want to execute "sp_123" but I could not figured that out, sp_xyz already declared in sp_123 I do not have any problem with sql part. I want learn how I execute sp_123 for takes value from 1st gridview to send 2nd gridview.

What I have tried:

I have been trying to get value with databind, SetOutData, I listed object and I get value but I could not show in 2nd gridview, I am losing data somewhere.

推荐答案

我能想到的最简单,最快的是



The easiest and the quickest i could think of is

private void Form1_Load(object sender, EventArgs e)
		{
			DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
			row.Cells[0].Value = "XYZ";
			row.Cells[1].Value = 50.2;
			dataGridView1.Rows.Add(row);

//copying it to grid two 
//considering they have same columns

			foreach (DataGridViewRow r in dataGridView1.Rows)
			{
				row = (DataGridViewRow)dataGridView2.Rows[0].Clone();
				row.Cells[0].Value = r.Cells[0].Value;
				row.Cells[1].Value = r.Cells[1].Value;
				dataGridView2.Rows.Add(row);
			}

		}


浏览以下链接

ASP.Net传递或将GridView行值发送到其他页面使用HyperLink [ ^ ]


这篇关于如何将gridview中的值发送到另一个gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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