How do I send null values to an integer type variable?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Learner

    How do I send null values to an integer type variable?

    Hello,
    I posted this question couple of days ago here in the forums.




    Thanks
    -L

  • Herfried K. Wagner [MVP]

    #2
    Re: How do I send null values to an integer type variable?

    "Learner" <pradev@gmail.c omschrieb:
    I posted this question couple of days ago here in the forums.
    http://groups.google.com/group/micro...69696722?hl=en
    .... and you got working replies. What's the problem?

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Learner

      #3
      Re: How do I send null values to an integer type variable?

      Hello Herfired,

      I tried with this as

      Dim PullAhead As Nullable(Of Boolean)
      PullAhead = Nothing
      If _lblpullahead.V isible = True Then
      PullAhead = Convert.ToInt32 (_drplPullAhead .SelectedValue. Trim)
      End If


      but when I send this as a parameter to a method in
      my Business Layer
      its throwing this error

      *************** *************** *************** *************** *************** ­************** ****

      System.InvalidO perationExcepti on was unhandled by user code
      Message="Nullab le object must have a value."
      Source="mscorli b"
      StackTrace:
      at
      System.ThrowHel per.ThrowInvali dOperationExcep tion(ExceptionR esource
      resource)
      at System.Nullable `1.op_Explicit( Nullable`1 value)
      at DealerQuestions US._btnGround_C lick(Object sender, EventArgs
      e) in
      D:\VSProjects\G roundingDemo\Gr oundingDemo\Dea lerQuestionsUS. aspx.vb:line

      143
      at System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
      at System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String
      eventArgument)
      at
      System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ­ostBackEvent(S tring

      eventArgument)
      at System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
      sourceControl, String eventArgument)
      at System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection
      postData)
      at System.Web.UI.P age.ProcessRequ estMain(Boolean
      includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
      *************** *************** *************** *************** *************** ­************** ***



      Am I missing some thing here?
      the code is exactly the same as we discussed in our previous postings.


      Thanks
      -L


      Herfried K. Wagner [MVP] wrote:
      "Learner" <pradev@gmail.c omschrieb:
      I posted this question couple of days ago here in the forums.
      http://groups.google.com/group/micro...69696722?hl=en
      >
      ... and you got working replies. What's the problem?
      >
      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • Claes Bergefall

        #4
        Re: How do I send null values to an integer type variable?

        Show the code where you get the error
        Also, why are you defining PullAhead as a nullable boolean and then put an
        integer in it?

        /claes



        "Learner" <pradev@gmail.c omwrote in message
        news:1155211337 .991868.155680@ 75g2000cwc.goog legroups.com...
        Hello Herfired,

        I tried with this as

        Dim PullAhead As Nullable(Of Boolean)
        PullAhead = Nothing
        If _lblpullahead.V isible = True Then
        PullAhead = Convert.ToInt32 (_drplPullAhead .SelectedValue. Trim)
        End If


        but when I send this as a parameter to a method in
        my Business Layer
        its throwing this error

        *************** *************** *************** *************** *************** ­************** ****

        System.InvalidO perationExcepti on was unhandled by user code
        Message="Nullab le object must have a value."
        Source="mscorli b"
        StackTrace:
        at
        System.ThrowHel per.ThrowInvali dOperationExcep tion(ExceptionR esource
        resource)
        at System.Nullable `1.op_Explicit( Nullable`1 value)
        at DealerQuestions US._btnGround_C lick(Object sender, EventArgs
        e) in
        D:\VSProjects\G roundingDemo\Gr oundingDemo\Dea lerQuestionsUS. aspx.vb:line

        143
        at System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
        at System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String
        eventArgument)
        at
        System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ­ostBackEvent(S tring

        eventArgument)
        at System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
        sourceControl, String eventArgument)
        at System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection
        postData)
        at System.Web.UI.P age.ProcessRequ estMain(Boolean
        includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
        *************** *************** *************** *************** *************** ­************** ***



        Am I missing some thing here?
        the code is exactly the same as we discussed in our previous postings.


        Thanks
        -L


        Herfried K. Wagner [MVP] wrote:
        "Learner" <pradev@gmail.c omschrieb:
        I posted this question couple of days ago here in the forums.
        http://groups.google.com/group/micro...69696722?hl=en
        >
        ... and you got working replies. What's the problem?
        >
        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        Working...