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

L

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
 
C

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



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top