Checking Value Detail View

  • Thread starter Thread starter Skip
  • Start date Start date
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
 
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
 
..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
 
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).
 
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
 
Back
Top