Custom field enum data type throwing cast error


Author
Message
Rob Toyias
Rob Toyias
StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)
Group: Forum Members
Posts: 31, Visits: 179
I am receving an error retreving a value from a field that has been customized to map to an enum.  In the BOM I set the ACTIONTYPECODE field to use the InspectionType Field Data Type. No problems there.   I build partial and get the following code in my .Designer file:

[Browsable(false),BusinessFieldDisplayInEditor(),Description("ACTIONTYPECODE"),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public InspectionType ACTIONTYPECODE
{
   
get
  
{
     
return (InspectionType)this.CurrentRow["ACTIONTYPECODE"];
   }
  
set
  
{
     
this.CurrentRow["ACTIONTYPECODE"] = value;
  
}
}

and here is the enum:

public enum InspectionType
{
   Foo= 0,
   Bar= 1,
   Zip= 2
}

Nothing too complex.  Stepping through the cose I can assign a value to ACTIONTYPECODE without issue.  But when I hit the 'Get' I end up with this error:

Cannot unbox 'this.CurrentRow["ACTIONTYPECODE"]' as a 'InspectionType'

Now this would make sense to me since the field seems to be stored as a string and last time I tried I had to do something like this: (InspectionType)Enum.Parse(typeof(InspectionType), "Foo"); to cast a string as an enum.  What am I screwing up? Ermm


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search