Home All Groups Group Topic Archive Search About

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

Author
9 Aug 2006 4:48 PM
Learner
Hello,
I posted this question couple of days ago here in the forums.

http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/6aaddaaf69696722?hl=en


Thanks
-L

Author
9 Aug 2006 9:17 PM
Herfried K. Wagner [MVP]
"Learner" <pra***@gmail.com> schrieb:
> I posted this question couple of days ago here in the forums.
> http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/6aaddaaf69696722?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/>
Author
10 Aug 2006 12:02 PM
Learner
Hello Herfired,

I tried with this as

Dim PullAhead As Nullable(Of Boolean)
    PullAhead = Nothing
    If _lblpullahead.Visible = 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.InvalidOperationException was unhandled by user code
  Message="Nullable object must have a value."
  Source="mscorlib"
  StackTrace:
       at
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource
resource)
       at System.Nullable`1.op_Explicit(Nullable`1 value)
       at DealerQuestionsUS._btnGround_Click(Object sender, EventArgs
e) in
D:\VSProjects\GroundingDemo\GroundingDemo\DealerQuestionsUS.aspx.vb:line

143
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
       at
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaiseP­ostBackEvent(String

eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
***************************************************************************­*****************



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:
Show quoteHide quote
> "Learner" <pra***@gmail.com> schrieb:
> > I posted this question couple of days ago here in the forums.
> > http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/6aaddaaf69696722?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/>
Author
10 Aug 2006 4:00 PM
Claes Bergefall
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" <pra***@gmail.com> wrote in message
news:1155211337.991868.155680@75g2000cwc.googlegroups.com...
Hello Herfired,

I tried with this as

Dim PullAhead As Nullable(Of Boolean)
    PullAhead = Nothing
    If _lblpullahead.Visible = 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.InvalidOperationException was unhandled by user code
  Message="Nullable object must have a value."
  Source="mscorlib"
  StackTrace:
       at
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource
resource)
       at System.Nullable`1.op_Explicit(Nullable`1 value)
       at DealerQuestionsUS._btnGround_Click(Object sender, EventArgs
e) in
D:\VSProjects\GroundingDemo\GroundingDemo\DealerQuestionsUS.aspx.vb:line

143
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
       at
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaiseP­ostBackEvent(String

eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
***************************************************************************­*****************



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:
Show quoteHide quote
> "Learner" <pra***@gmail.com> schrieb:
> > I posted this question couple of days ago here in the forums.
> > http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/6aaddaaf69696722?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/>