This is a migrated thread and some comments may be shown as answers.

Filter throwing Error when filtering Grid Column that includes NULLs

6 Answers 175 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Landon
Top achievements
Rank 2
Landon asked on 10 Feb 2012, 07:39 PM
Hi,

I have a RadFilter control hooked up to do advanced filtering on a RadGrid. When attempting to apply a filter on a column which contains NULLS in the DB, I get the infamous "Object reference not set to the instance of an object" error. Since I cannot change my database structure, and the Nulls are required, is there anything I can do to allow my RadFilter to filter on these columns?

Best Regards,
Landon

6 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 13 Feb 2012, 04:57 PM
Hello Landon,

I could not reproduce the problem as evidenced by the attached sample. Could you take a look at it and let me know what modification is needed for the issue to be replicated. The column that contains nulls is CategoryID.


Greetings, Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Landon
Top achievements
Rank 2
answered on 13 Feb 2012, 05:47 PM
Hi Tsvetoslav,

I appreciate your attempts to replicate the error, but I believe you've forgotten to attach the sample project as I cannot see where to download it. 

Thanks,
Landon
0
Tsvetoslav
Telerik team
answered on 14 Feb 2012, 09:24 AM
Hi Landon,

Sorry for that - here you go, the sample should be attached to this post.

Regards,
the Telerik team

Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Landon
Top achievements
Rank 2
answered on 15 Feb 2012, 11:02 PM
Hi Tsvetoslav,

Unfortunately I could not replicate the error within your example, which makes sense because I am doing things a bit differently on my end. In my application, I am using a DBML as my Datasource which is queried by a Linq statement within the "OnNeedDataSource" method on my RadGrid.

Fortunately, I was able to find out exactly what is throwing the "Object reference not set to an instance of an object" error. The error is being bubbled up directly from my DBML's Designer layer ("datasource.designer.cs"). 

One of the fields that is throwing this error is my "Account" field on my view. When filtering on this field, the error is thrown immediately after the RadFilter loops onto the first record with a NULL as Account. I've shown the Designer code below.

[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Account", DbType="VarChar(200)")]
        public string Account
        {
            get
            {
                return this._Account;   //THROWING ERROR WHEN THIS FIELD IS FOUND TO BE NULL
            }
            set
            {
                if ((this._Account != value))
                {
                    this._Account = value;
                }
            }
        }

NOTE: I am mainly attempting to use the "contains" expression type, but the "IsNull" expression type seems to work perfectly fine, and finds the NULLS. 

I don't believe it's my DBML that is the problem because this View Binds to all of my Grids fine when not being searched (with and without nulls).

I noticed in another thread that one of the Telerik Reps asked "Does your database contain Nulls? Try removing them and then testing" but no one responded. Is there a potential problem with the RadFilter and Nulls in the Database, in some situations?
0
Tsvetoslav
Telerik team
answered on 21 Feb 2012, 09:06 AM
Hello Landon,

Could not replicate the issue even with a dbml data context. Attached is the new sample.


All the best,
Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Tsvetoslav
Telerik team
answered on 21 Feb 2012, 09:11 AM
Hello Landon,

Just an extra note: please, remove the DataSourceID property of the RadGrid and MasterTableView tags in the mark-up. The column that contains nulls and which you can apply a Contains filter operator on, is the Quantity per Unit one.


All the best,
Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Filter
Asked by
Landon
Top achievements
Rank 2
Answers by
Tsvetoslav
Telerik team
Landon
Top achievements
Rank 2
Share this question
or