I am tring to convert a string to a smartdate for a grid column. The column is a date column with a dropdown tool. I need to be able to see null dates of course. here is my current code.
The datacolumn:
DataColumn onsetDate = new DataColumn("OnsetDate", typeof(SmartDate));dataTable.Columns.Add(onsetDate);
The code to add the date:
SmartDate dateIn = null; if (diagnosis.OnsetDate == null){
row[
"OnsetDate"] = dateIn;}
else{
dateIn = diagnosis.OnsetDate;
row[
"OnsetDate"] = dateIn;}
The problem is the diagnois.OnsetDate is a string value. How do i change this to be a SmartDate.
My product uses CSLA 1.0
Any help would be appreciated.
Thanks
In CSLA 1.x SmartDate was a reference type, so you need to create an instance:
SmartDate dateIn = new SmartDate();
Then you can set or retrieve its Text property to work with the value as a string:
string x = dateIn.Text;
dateIn.Text = "1/1/08";
In CSLA 2.0+ SmartDate is a value type (struct) and so the semantics are a bit different, but you still use the Text property when dealing with string values.
Copyright (c) Marimer LLC