AdvancedDataGridView 排序和筛选器不起作用

AdvancedDataGridView Sort and Filter not working

我有 AdvanceDataGridView "customerTransactionDGV,数据源 = customersTransactionsBindingSource。

我正在使用以下 LINQ 代码更改 CustomerComboBox 的 SelectionChangeCommitted 事件中的数据源。

this.customersTransactionsBindingSource.DataSource = dbContext.CustomersTransactions.Where(t => t.CustomerId.Equals(customerId)).ToList();
this.customersTransactionsTableAdapter.Fill(this.akDbDataSet.CustomersTransactions); 

之后过滤器和 datagridview 排序不起作用。

删除第一行代码使其工作,但我需要这一行来使用在 CustomerComboBox 中选择的单个用户的事务填充 datagridview。

这行代码:

this.customersTransactionsTableAdapter.Fill(this.akDbDataSet.CustomersTransactions); 

显然是从数据库下载所有客户交易。如果是真的,请不要这样做

打开您的数据集,找到 CustomersTransactions TableAdapter,右键单击它,选择“添加查询”,然后输入:

SELECT * FROM CustomersTransactions WHERE CustomerId = @custId

将其命名为 FillByCustomerId(对于 getdataby 也是如此)

现在在您的代码中,不理会绑定源,停止更改其数据源(其数据源应设置为,并保持 this.akDbDataSet.CustomersTransactions),然后调用:

this.customersTransactionsTableAdapter.FillByCustomerId(this.akDbDataSet.CustomersTransactions, customerId);