Checking Value Detail View

S

Skip

Hi All,
I am trying to check a fields value (boolean in this case) in the
ItemUpdated event. The following does not work. I am very new to .NET
(VB6 guy) so sorry if this is way off.

If Me.DetailsView1.Fields.Item(6) = True Then
'do something
End If


It complains with the following error.


Error 1 Operator '=' is not defined for types
'System.Web.UI.WebControls.DataControlField' and
'Boolean'.
H:\Programming\Web\MSF_OP_Compliance_New\OP_Comp_Detail.aspx.vb 8
12 H:\...\MSF_OP_Compliance_New\


Please help. Very simple thing is causing me headaches. Thanks
 
W

wfairl

You need

If DirectCast(Me.DetailsView1.Fields.Item(6).Value,boolean) = true Then

Or more simply:

If DirectCast(Me.DetailsView1.Fields.Item(6).Value,boolean) Then
 
S

Skip

..value is not valid for this. It complains about not being a member.
All I want to do is to access/check the fields value. I should not have
to do any datatype conversions?? I tried some other things using
DataItem and it complains about a NullReferenceException.

If Me.DetailsView1.DataItem(6) = True Then

End If


Thanks
 
W

wfairl

Also, you're not doing any data type conversions but you must do a cast
to avoid compiler errors (if option strict is on, which it should be).
 
S

Skip

Thanks that worked great. Not what I was expecting, it shows my .NET
inexperience.

Another question since you were so helpful.

This check is being used to set another field's value. What is the
proper way to directly set a fields value?

Thanks
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top