在更多的第2部分的另一个gridview中从gridview传输数据 [英] transfer data from gridview in another gridview part 2 with more info

查看:67
本文介绍了在更多的第2部分的另一个gridview中从gridview传输数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将选定的数据转移到一种形式到另一种形式,并显示到gridview.
我有一种表格可以在gridview中显示有关产品的信息(例如ProductID,ProductName和UnitPrice)
还有一个按钮.

现在,当我单击首页的网格视图中显示的按钮时,我想将我的首页重定向到第二页.
在第二页上,还有一个网格将显示从首页按钮单击事件转移的产品信息.

我的问题是...
1.我对gridviews项目事件一无所知
2.而且我也不知道如何将数据传输到其他形式

一次只能将一行转换为另一种形式..

请帮我

I need to Transfer selected data to one form to an other form, and displayed to gridview.
i have one form that will display information about product like (ProductID, ProductName and UnitPrice) in gridview
also there is one button.

now i want to redirect my first page to second page when i click on that button shown in gridview of first page.
and on the second page there is also one grid that will show the product information transferred from first page button click event.

my Problem is...
1. I have no knowledge about gridviews item events
2. and also i dont know how to transfer data to an other form

only one row at a time will be transfer to an other form..

pleas help me

推荐答案

*在datagridview1上为"CellMouseClick"创建一个事件

* Create an event for "CellMouseClick" on datagridview1

private void datagridview1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
          if (e.Button == MouseButtons.Left)
           {
/// checks the column by it's name                   
if (e.ColumnIndex == datagridview1.Columns["colSelect"].Index)
                   {
                   DataGridViewRow currentRow = dataGridView1.Rows[e.RowIndex];
                dataGridView2.Rows.Add(currentRow.Cells["ProductID"].Value, currentRow.Cells["ProductName"].Value, currentRow.Cells["UnitPrice"].Value);
                   }

                }
            }




对于您的第一个问题,我建议您阅读以下链接

还有一件事情是每个控件都具有按钮单击事件或更改事件之类的事件.在数据控件中没有那么困难.

http://www.deeptraining.com/litwin/Litwin_ASP_DataControlsTips.pdf


数据控件具有一些事件链接itemcommand,editcommand,delete命令..

在这里itemcommand表示,当您单击数据控件内的任何按钮时,它会升高

并谈到第二个问题

我们不会将整个数据从一页传递到另一页,而只是传递您在第一页中选择的产品的productid.

在第二页中,我们从数据库中检索基于该productid的完整信息,并显示在数据控件中.


最好的


For your first problem,I suggest to read following links

and one more thing is every control has event like button click events or changed events.there is no such difficult in data controls .

http://www.deeptraining.com/litwin/Litwin_ASP_DataControlsTips.pdf


data controls has some events link itemcommand,editcommand,delete command..

Here itemcommand means it''ll raise when u click on any button inside data control

And comming to your second problem

we don''t pass entire data from one page to another page.we just pass productid of that product which you selected in first page.

In the second page we retrieve full information based on that productid from database and show in data control.


All the Best


这篇关于在更多的第2部分的另一个gridview中从gridview传输数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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