如何使用sql server数据库表过滤datagrid,if上有错误(view!= null)view.filter = null [英] How to use filtering datagrid with sql server database table, error on if(view!=null)view.filter=null

查看:81
本文介绍了如何使用sql server数据库表过滤datagrid,if上有错误(view!= null)view.filter = null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if (query == null)
               {
                   //clear the filter if exisits begin
                   System.ComponentModel.ICollectionView view
                       = System.Windows.Data.CollectionViewSource.GetDefaultView(dataGrid.ItemsSource);
                   if (view != null) view.Filter = null;
                   //clear the filter if exisits end

                   query = new QueryController();
                   DataGridExtensions.SetDataGridFilterQueryController(dataGrid, query);
               }

推荐答案

我做的是如果Null那么string.Empty来自数据库并反转它返回Param = null,当它是string.empty时。对于数字,我使用.MinValue函数执行相同的概念。

在存储过程中,我使用where子句执行以下操作。

What I do is if Null then string.Empty coming from the database and reverse it going back Param=null when it is string.empty. For numbers I do the same concept with the .MinValue function.
Within the stored procedure I do the following withing the where clause.
Where (@stringParam is null or column = '%' + @stringParam + '%')


这篇关于如何使用sql server数据库表过滤datagrid,if上有错误(view!= null)view.filter = null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆