是否可以将一组特定的数据行行绑定到DataGridView [英] Is it possible to bind a particular set of rows of datatable to DataGridView
本文介绍了是否可以将一组特定的数据行行绑定到DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将一组特定的数据行绑定到DataGridView?
ProductExp talbe有
ProductExpNo
ProductNo
ExpDate
例如,我想绑定ProductNo = 001的行
i还需要该数据表中的其他行,但只想显示一组行到datagridveiw
Is it possible to bind a particular set of rows of datatable to DataGridView?
ProductExp talbe has
ProductExpNo
ProductNo
ExpDate
for example, i want to bind rows that has ProductNo=001
i also need other rows in that datatable but only want to show a set of rows to datagridveiw
推荐答案
是。在数据表上设置一个条件,然后将其绑定到数据网格。
您还可以使用带有where子句的存储过程/查询来实现相同的结果。
Yes. Set a condition on your datatable, then bind it to your datagrid.
You could also use a stored procedure/query with a where clause to achieve the same result.
您好,
是的,您可以使用数据表的select子句来完成此操作。
一旦将数据填充到数据表中,请使用如下的select子句。
//这个将数据填充到数据表中。
DataTable dtEmployees = GetData(splGetEmployees);
string strEmpID = 501;
string strTitle =经理;
string strFilterOption =EmpId =+ strEmpID +AND Title =+ strTitle;
//使用datatable的SELECT子句将数据与已过滤的行绑定
datagrid.DataSourse = dtEmployees.Select(strFilterOption);
datagrid.Databind();
享受编码....
干杯
Kumar
Hi,
Yes, you can do this by using select clause of data table.
Once you populate your data into data table, use select clause as below.
//This will populate your data into data table.
DataTable dtEmployees= GetData(splGetEmployees);
string strEmpID = 501;
string strTitle = "Manager";
string strFilterOption= "EmpId= " + strEmpID+ " AND Title = " + strTitle;
// bind the data with filtered rows using SELECT clause of datatable
datagrid.DataSourse = dtEmployees.Select(strFilterOption);
datagrid.Databind();
Enjoy coding....
Cheers
Kumar
这篇关于是否可以将一组特定的数据行行绑定到DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文