locked
I get Conversion from type 'DBNull' to type 'String' is not valid. RRS feed

  • Question

  • User1479750397 posted

    I get the following errors when I try and access certain pages.  It is caused by not populating all the text boxes with data and subsequent viewing causes these conversion errors.  Does any one else experience this?  How have you guys worked around this problem?

    Conversion from type 'DBNull' to type 'String' is not valid.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.

    Source Error:

    Line 23:                         'We are in new mode
    Line 24:                         FormView1.ChangeMode(FormViewMode.Insert)
    Line 25:                         Dim lp As LocationsPicker = CType(FormView1.FindControl("LocationPicker1"), LocationsPicker)
    Line 26:                         lp.LocationID = Nothing
    Line 27:                         Dim dp As DurationPicker = CType(FormView1.FindControl("dtpicker"), DurationPicker)

    Wednesday, March 22, 2006 12:39 AM

All replies

  • User-1476513399 posted

    See this thread for a quick fix:

    http://forums.asp.net/1194730/ShowPost.aspx

    In particular ... Lutz2 - Quick Fix.

    This is not exactly your same error location, but the idea is the same.  In Lutz2's case, ie where his error is occuring ... there are some bigger underlying problems ... which I am working.  But for now, his fix gets around it.  See if you can apply it to your situation.

    <>

    Wednesday, March 22, 2006 2:16 AM