Trying to do the following:
order.ExpirationDate =(DateTime) ( ExpMonth + "/" + ExpYear);
ExpMonth, Expyear are both ints.
Trying to do the following:
order.ExpirationDate =(DateTime) ( ExpMonth + "/" + ExpYear);
ExpMonth, Expyear are both ints.
This is going to be better for you:
order.ExpirationDate = new DateTime(ExpYear, ExpMonth, 1)
You need to use:
DateTime.Parse(ExpMonth.ToString() + "/" + ExpYear.ToString());
Try this:
DateTime dt;
if (DateTime.TryParse(ExpMonth + "/" + ExpYear, out dt))
{
// success
}
Try creating a new DateTime using the constructor which takes month and year as parameters (it also takes a day, but you can default to 1) instead of casting a string, it's much cleaner and easier.