首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DataTables DataRelation反向右外部联接

DataTables DataRelation反向右外部联接
EN

Stack Overflow用户
提问于 2013-07-13 00:34:53
回答 2查看 556关注 0票数 0

我有三个数据网格视图(部门、员工、EmployeeNotInDepartment)。我已经基于DataRelations填充了部门和员工数据网格视图(见下文)。我认为肯定有一种明显简单的方法来填充EmployeeNotInDepartment数据网格视图。有什么想法吗?我希望我不需要使用linq。

代码语言:javascript
复制
public Form1()
{
        InitializeComponent();

        dtDepartment = FillDepartmentList();
        dtEmployee = FillEmployeeList();
        dsDepartmentEmployees = new DataSet();

        // Add tables to dataset
        dsDepartmentEmployees.Tables.Add(dtDepartment);
        dsDepartmentEmployees.Tables.Add(dtEmployee);

        // Create table relationship
        dsDepartmentEmployees.Relations.Add("DepartEmpRelation", dtDepartment.Columns["DepartmentNumber"], dtEmployee.Columns["DepartmentNumber"],true);

        BindingSource bsDepartment = new BindingSource();
        bsDepartment.DataSource = dsDepartmentEmployees;
        bsDepartment.DataMember = "table1";

        BindingSource bsEmployee = new BindingSource();
        bsEmployee.DataSource = bsDepartment;
        bsEmployee.DataMember = "DepartEmpRelation";

        dataGridView1.DataSource = bsDepartment;
        dataGridView2.DataSource = bsEmployee;

}
EN

回答 2

Stack Overflow用户

发布于 2013-07-13 01:11:49

如果您坚持不使用LINQ,那么您可以使用DataView并在RowFilter属性中指定您的过滤器(它可能是您不想显示的in的逗号分隔列表)

DataView上使用RowFilterThis is how

票数 0
EN

Stack Overflow用户

发布于 2013-07-13 01:18:52

正如@Rwiti所建议的,您可以使用DataView的RowFilter属性,并且可以根据该属性定义适当的表达式来筛选出行。

请查看以下链接,其中列出了包括NOT IN在内的各种RowFilter示例

http://www.csharp-examples.net/dataview-rowfilter/

但是,如果你没有任何理由不使用Linq (即必须使用.net 2.0),那么就使用它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17619717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档