Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for ASP.NET Web Forms / Object of type System.DBNull cannot be converted to type System.Nullable`1[System.Decimal]

Object of type System.DBNull cannot be converted to type System.Nullable`1[System.Decimal]

New Discussion
Ross
Ross asked on Feb 8, 2012 3:00 PM

Hello,

I am getting the above error when I try to change a grid value from a decimal number to null.  I am using an ObjectDataSource to populate a WebHierarchicalDataGrid, version 10.3.  I found a post elsewhere that suggested setting the ObjectDataSource property ConvertNullToDBNull to False, but in my case it is False already.  Any ideas?

Thank you,

Ross

Sign In to post a reply

Replies

  • 0
    Georgi Georgiev
    Georgi Georgiev answered on Jan 26, 2012 8:25 AM

    Hello Ross,

     

    Thank you for posting in our community. I found a lot of posts according to this error. It does not seems to be something connected with IG controls it is more because of the null values returned from the database. For some reason they are set to DBNull.Value. If you are able to provide us a simple sample that reproduces this issue. I could look into it and investigate it further.

     

    Looking forward to hear from you.

     

    Sincerely,

    Georgi Sashev

    Developer Support Engineer

    Infragistics, Inc.

    http://www.infragistics.com/support

    • 0
      Ross
      Ross answered on Jan 26, 2012 1:38 PM

      Hi Georgi,

      Thank you for your quick reply.  I put together a test project that reproduces this problem.  I couldn't attach the whole project because the default IG styles and graphics were loaded into it, so I just zipped up my code files.

      Regards,

      Ross

      • 0
        Georgi Georgiev
        Georgi Georgiev answered on Jan 26, 2012 3:50 PM

        Hello Ross,

         

        Thank you for the sample code. I am working on this. I was able to reproduce this exception. I will update you with my progress as soon as possible.

         

        Sincerely,

        Georgi Sashev

        Developer Support Engineer

        Infragistics, Inc.

        http://www.infragistics.com/support

      • 0
        Georgi Georgiev
        Georgi Georgiev answered on Feb 2, 2012 12:49 PM

        Hello Ross,

         

        The only way this will work is to set

         

        public class TestObject

        {

               public int Key { get; set; }

               public decimal Amount { get; set; }

        }

         

        The amount like this. Which will prevent it to be null and this way when you delete the value in the column it will not throw an exception and the value shown in the grid will be 0.

         

        I hope this helps.

         

        Sincerely,

        Georgi Sashev

        Developer Support Engineer

        Infragistics, Inc.

        http://www.infragistics.com/support

      • 0
        Ross
        Ross answered on Feb 2, 2012 1:05 PM

        While your answer has the virtue of being obvious, it is not helpful.  Can you do any better?  You are basically saying that the Infragistics grid doesn't handle nulls fully the way it should.  I can back that up with the fact I have tried this same exercise with other grids, and they work fine.

        As a possible work-around, I am going to explore having the grid display all zero values as blank.  If you have anything to suggest on how to best make that work, that will be appreciated.  While it isn't a very satisfying answer, I have to get the job done, and it is too late to switch off the Infragistics grids right now.

      • 0
        Georgi Georgiev
        Georgi Georgiev answered on Feb 2, 2012 1:52 PM

        Hello Ross,

         

        Here I found this forum post:

         

        you can try this approach. And let me know if it works in your case.

         

         

        I hope this helps.

         

        Sincerely,

        Georgi Sashev

        Developer Support Engineer

        Infragistics, Inc.

        http://www.infragistics.com/support

      • 0
        Ross
        Ross answered on Feb 2, 2012 6:29 PM

        Thank you for the link.  It looks like it may be helpful, but I will need some time to try it out.  I will keep you posted.

        Regards,

        Ross

      • 0
        Georgi Georgiev
        Georgi Georgiev answered on Feb 3, 2012 8:41 AM

        Hello Ross,

         

        I am waiting for your update on this.

         

        Sincerely,

        Georgi Sashev

        Developer Support Engineer

        Infragistics, Inc.

        http://www.infragistics.com/support

      • 0
        Ross
        Ross answered on Feb 3, 2012 1:24 PM

        Yes, thank you for waiting.  I need a few days to get to this because of some other things that have come up.

      • 0
        Georgi Georgiev
        Georgi Georgiev answered on Feb 7, 2012 3:18 PM

        Hello Ross,

         

        Any update on this?

         

        Sincerely,

        Georgi Sashev

        Developer Support Engineer

        Infragistics, Inc.

        http://www.infragistics.com/support

      • 0
        Ross
        Ross answered on Feb 7, 2012 3:32 PM

        Hi Georgi,

        Thank you for asking.  I hope to work on this by the end of this week.

        Regards,

        Ross

      • 0
        Ross
        Ross answered on Feb 8, 2012 2:31 PM

        Hi Georgi,

        I have tried to work with the link that you sent, but without success.  Because I need to move ahead with the project, I am going to try a different approach, displaying null values as zero on the screen and then storing them as null in the database.  The users may not go for it, and if not, then I will have to go back to the drawing board.  So, I wouldn't consider this question answered, but I am dropping the question indefinitely.

        Regards,

        Ross

      • 0
        Georgi Georgiev
        Georgi Georgiev answered on Feb 8, 2012 3:00 PM

        Hello Ross,

         

        Thank you for the update.

        If you come back to this question or in case you have any other, do not hesitate to contact me, I will be glad to assist you.

         

        Sincerely,

        Georgi Sashev

        Developer Support Engineer

        Infragistics, Inc.

        http://www.infragistics.com/support

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Ross
Favorites
0
Replies
13
Created On
Feb 08, 2012
Last Post
14 years ago

Suggested Discussions

Created by

Created on

Feb 8, 2012 3:00 PM

Last activity on

Feb 11, 2026 5:16 PM