如何处理数据网格视图控件 [英] how to handle datagrid view control

查看:76
本文介绍了如何处理数据网格视图控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我使用datagridview添加多个详细信息.我在gridview中有许多列,例如产品代码,产品名称,数量,费率,总计等
当我在产品代码"列下面的行中键入产品代码时,对应的产品名称应自动出现在下一列中
我将如何获取该对应的pdt名称.我不想要db代码,而是想要前端代码.如何获取这些值.

在此先感谢
Amrutha

Hi all

Iam using datagridview to add multiple details.i have number of coloumns in gridview like product code ,product name,qty,rate,total etc
when i type product code in the row below ''product code'' column corresponding product name should come automatically in the next column
how will i get that corresponding pdt name.I dont want db code instead i want front end code .How to get those values.

Thanks in advance
Amrutha

推荐答案

hi,

它可以通过两种方式完成.

方法1:
单击文本框网格视图,从数据库获取相应的数据.
可能会很慢.



方法2:
1.从数据库获取数据集.
2.将其存储为数据表.
3.输入产品代码后,
i)调用接受文本作为参数的方法.
ii)在数据表中搜索相应的产品名称,如
datatable.select(您的查询).
iii)返回产品名称
4.在网格的文本框中显示返回的产品名称.


数据表选择示例


It can be done in 2 ways.

Method 1:
Get the corresponding data from DB on click of the text box grid view.
Which might be slow.

or

Method 2:
1.Get the dataset from the db.
2.Store it as a datatable.
3.After you enter the product code ,
i) call a method that accepts the text as parameter.
ii)search the corresponding product name in the datatable like
datatable.select(YOUR QUERY) .
iii)Return the product name
4.display the product name returned in the textbox in grid.


Example of datatable select
// Create a table of five different people.
	// ... Store their size and sex.
	DataTable table = new DataTable("Players");
	table.Columns.Add(new DataColumn("Size", typeof(int)));
	table.Columns.Add(new DataColumn("Sex", typeof(char)));

	table.Rows.Add(100, ''f'');
	table.Rows.Add(235, ''f'');
	table.Rows.Add(250, ''m'');
	table.Rows.Add(310, ''m'');
	table.Rows.Add(150, ''m'');

	// Search for people above a certain size.
	// ... Require certain sex.
	DataRow[] result = table.Select("Size >= 230 AND Sex = ''m''");


希望这会有所帮助.


Hope this helps.


这篇关于如何处理数据网格视图控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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