如何使用表格视图从表中检索数据并将检索到的数据插入到另一个表中 [英] How to retrieve data from a table and inserting the retrieving the data into a another table using a gridview

查看:83
本文介绍了如何使用表格视图从表中检索数据并将检索到的数据插入到另一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设有一个4列的网格视图.第一列有一个下拉列表,该下拉列表绑定到表(员工)的字段,其他三列具有三个文本框.这些文本框绑定到不同表(项目)的三个字段.现在,我想将表employee中的所有employee ID分配给下拉列表,并将相应的数据插入到项目表中.我不知道该怎么做.所以,请帮助我.

Suppose there is a grid view with 4 column . First column has a drop downlist which is bind to a field of a table(employee) and other three columns have three text boxes .These text boxes are bind to three field of a different table(projects). Now I want to assign all the employee ID from the table employee to the drop down list and insert the corresponding data into the project table. I don''t know how to do it . So , please help me.

推荐答案

我不知道您如何将数据准确地绑定到gridview中,所以我会告诉您您必须做什么,然后您才能做到这一点用您自己的代码


您必须检查dataGridView的单元格结束编辑事件,并检查您的第一列的值,并用与它绑定数据的方式填充其他列


I dont know how exactly do you bind your data into your gridview so I will tell you what you have to do and you make this on your own code


you have to check the cell end edit event for the dataGridView and check for the value of the first column of yours and fill the other columns the way you bind your data with it


private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
              {
                  if(dataGridView1.CurrentRow.Cells[0].value=="whatever you check")
                    {
                        //bind the data for the other columns 
                    }
              }


这篇关于如何使用表格视图从表中检索数据并将检索到的数据插入到另一个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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