[英]dataGridView Row Filteration using NAV web services
I am trying to create a filterable data view of data which I get it through a web service in NAV 2009. 我正在尝试创建数据的可过滤数据视图,该视图是通过NAV 2009中的Web服务获取的。
I created a windows form and pulled the essential data from a NAV page, created an array and showed in a dataGridView using web services. 我创建了一个Windows窗体,并从NAV页面中提取了基本数据,创建了一个数组,并使用Web服务在dataGridView中显示了它。
What I need now, is to filter by row the data which I have in my dataGridView. 我现在需要的是逐行过滤dataGridView中的数据。
My code would be 我的代码是
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);
}
But in the last line of my code which contains dataGridViewFields is not in the context. 但是在我的代码的最后一行中,包含dataGridViewFields的内容不在上下文中。 If I want to modify my coding how should I do? 如果我想修改编码怎么办?
Thank you. 谢谢。
If you want to read filtered data why don't you use first parameter filterArray
of ReadMultiple
function which reads a filtered set of records 如果要读取过滤的数据,为什么不使用ReadMultiple
函数的第一个参数filterArray
来读取过滤的记录集
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);
In other way, while publishing the page you can set the filter in page's SourceTableView property. 换句话说,在发布页面时,您可以在页面的SourceTableView属性中设置过滤器。 This will gives only those fields which are follow the filter criteria. 这将仅提供遵循过滤条件的那些字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.