StrataFrame Forum

What is this error?

http://forum.strataframe.net/Topic1180.aspx

By Daniel Essin - 5/9/2006

In this code tha references a bo:

PatientSelectedEventArgs pa = new PatientSelectedEventArgs(boPatientSearch1.MRN, boPatientSearch1.LASTNAME, boPatientSearch1.FIRSTNAME, boPatientSearch1.BIRTHDATE, boPatientSearch1.GENDER, boPatientSearch1.SSN);



with this set of event args:

public class PatientSelectedEventArgs : EventArgs

{

public PatientSelectedEventArgs(string MRN, string LastName, string FirstName, DateTime Birthdate, string Gender, string SSN)

{

this.MRN = MRN;

this.LastName = LastName;

this.FirstName = FirstName;

this.SSN = SSN;

this.Gender = Gender;

this.Birthdate = Birthdate;

this.IDSTRING = "MRN: " + MRN + ", Name: " + LastName + ", " + FirstName + ", Gender: " + Gender + ", Birthdate: " + Birthdate.ToShortDateString();

}

public string MRN;

public string IDSTRING;

public string LastName;

public string FirstName;

public string Gender;

public string SSN;

public DateTime Birthdate;

}





what is this?

Argument '4': cannot convert from 'System.DateTime?' to 'System.DateTime'   
By StrataFrame Team - 5/10/2006

Are you returning a nullable generic value for the DateTime?  If not, what is the value of the variable you're trying to pass?
By Daniel Essin - 5/10/2006

yes, nullable generic
By StrataFrame Team - 5/10/2006

When you pass a nullable generic from a property, you will need to pass the propertie's .Value member.  Like this:

new PatientSelectedEventArgs(boPatientSearch1.MRN, boPatientSearch1.LASTNAME, boPatientSearch1.FIRSTNAME, boPatientSearch1.BIRTHDATE.Value, boPatientSearch1.GENDER, boPatientSearch1.SSN);

Otherwise, you're passing a NullableGeneric value into an actual value.

By Daniel Essin - 5/10/2006

I think that I tried that and got the same message. The only thing that worked was

DateTime.Parse(bo.NullableGenericDate.Value.ToShortDateString()).
By StrataFrame Team - 5/11/2006

That's very odd... I've never heard of .NET not being able to cast an object to its own type.