CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2014
    Posts
    3

    [RESOLVED] why this code crashes and how to fix it

    Db allows null in the table.. Thank for your help... hope to post in the right place..



    Protected Sub ASPxGridView1_CustomUnboundColumnData(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs) Handles ASPxGridView1.CustomUnboundColumnData
    If (e.Column.FieldName = "total1") Then
    apples = Convert.ToInt32(e.GetListSourceFieldValue("apples"))<<---Object cannot be cast from DBNull to other types.
    peach = Convert.ToInt32(e.GetListSourceFieldValue("peach"))
    e.Value = apples + peach

    End If
    End Sub

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: why this code crashes and how to fix it

    You'd need to check it for nulls first, then proceed
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2014
    Posts
    3

    Re: why this code crashes and how to fix it

    I re-set the table column [apples] data type numeric(3,0) allow nulls unchecked, default value or binding to ((0)) but the default don't show in the table. when i rebuild the data-grid with a new sql data source default 0 don't show??? Is their another way around this?? thanks for the help.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: why this code crashes and how to fix it

    DevExpress? Why not contact them? Their support is paid by you or your employer
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Feb 2014
    Posts
    3

    Re: why this code crashes and how to fix it

    fixed it.. my boss said wait until he gets back into town to look at it.. Too late fixed it myself.. thanks for the help anyhow...

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: why this code crashes and how to fix it

    Quote Originally Posted by iwzhidden View Post
    fixed it.. my boss said wait until he gets back into town to look at it.. Too late fixed it myself.. thanks for the help anyhow...
    I am happy you have fixed it yourself. Please post your solution so that members encountering the same problem can be able to get help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured