Filter throwing Error when filtering Grid Column that includes NULLs

7 posts, 0 answers
  1. Landon
    Landon avatar
    66 posts
    Member since:
    Nov 2010

    Posted 10 Feb 2012 Link to this post

    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
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 13 Feb 2012 Link to this post

    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 >>
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Landon
    Landon avatar
    66 posts
    Member since:
    Nov 2010

    Posted 13 Feb 2012 Link to this post

    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
  5. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 14 Feb 2012 Link to this post

    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 >>
  6. Landon
    Landon avatar
    66 posts
    Member since:
    Nov 2010

    Posted 15 Feb 2012 Link to this post

    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?
  7. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 21 Feb 2012 Link to this post

    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 >>
  8. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 21 Feb 2012 Link to this post

    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 >>
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017