Вопрос

I am trying to create a filterable data view of data which I get it through a web service in NAV 2009.

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.

What I need now, is to filter by row the data which I have in my 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. 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

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. This will gives only those fields which are follow the filter criteria.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top