0

我正在尝试创建数据的可过滤数据视图,我通过 NAV 2009 中的 Web 服务获取它。

我创建了一个 Windows 窗体并从 NAV 页面中提取基本数据,创建了一个数组并使用 Web 服务在 dataGridView 中显示。

我现在需要的是按行过滤我在 dataGridView 中的数据。

我的代码是

private void LoadDataGrid()
    {

        WS_GLEntry_Service GLEntryService = new WS_GLEntry_Service();
        GLEntryService.UseDefaultCredentials = true;

        WS_GLEntry[] Entries = GLEntryService.ReadMultiple(null,null,0);
        dataGridView1.DataSource = Entries;

        (dataGridViewFields.DataSource as DataTable).DefaultView.RowFilter = string.Format("Field = '{0}'", textBox1.Text);
    }

但是在包含 dataGridViewFields 的代码的最后一行中,不在上下文中。如果我想修改我的编码我应该怎么做?

谢谢你。

4

2 回答 2

1

如果您想读取过滤后的数据,为什么不使用函数的第一个参数来filterArray读取过滤后的记录集ReadMultiple

List<Customer_Filter> filterArray = new List<Customer_Filter>();
Customer_Filter nameFilter = new Customer_Filter();
nameFilter.Field = Customer_Fields.Name;
nameFilter.Criteria = "S*";
filterArray.Add(nameFilter);
Customer[] custList = service.ReadMultiple(filterArray.ToArray(), null, 100);
于 2013-12-03T08:54:44.473 回答
0

换句话说,在发布页面时,您可以在页面的 SourceTableView 属性中设置过滤器。这将只给出那些遵循过滤条件的字段。

于 2016-05-20T11:57:51.237 回答