locked
CBool(expression) fails - but why? RRS feed

  • Question

  • User-1056187187 posted

    Hi

    Its might a stupid question but i don't get why this ends in an exception:

    Line 241: If CBool(e.CommandName) Then 
    Line 242: dataTable.Item("DoneDate") = Date.UtcNow Line 243: End If

    e.CommandName is 'fdcf1908-be5c-4808-a9a8-287bfc63' - a normal string - or not?

    Any help is much appreciated!

    greetings cetrick

    Edit:

    Whole StackTrace:

    [FormatException: Input string was not in a correct format.]
       Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +201
       Microsoft.VisualBasic.CompilerServices.Conversions.ToBoolean(String Value) +145
    
    [InvalidCastException: Conversion from string "fdcf1908-be5c-4808-a9a8-287bfc63" to type 'Boolean' is not valid.]
       Microsoft.VisualBasic.CompilerServices.Conversions.ToBoolean(String Value) +349
       EventActions.SetActionDone(Object sender, CommandEventArgs e) in xxx.vb:241
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +108
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

    Tuesday, August 23, 2011 5:15 AM

Answers

  • User-1516073966 posted

    Your command name value is not a valid boolean value.

    It should be one of the following

    CBool("True")
    CBool("False")
    CBool(1)
    CBool(0)
    CBool("true")
    CBool("false")
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 23, 2011 5:38 AM

All replies

  • User-1516073966 posted

    Your command name value is not a valid boolean value.

    It should be one of the following

    CBool("True")
    CBool("False")
    CBool(1)
    CBool(0)
    CBool("true")
    CBool("false")
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 23, 2011 5:38 AM
  • User-1056187187 posted

    ty, how stupid from me!

    Tuesday, August 23, 2011 6:32 AM