My Date Time Column keeps posting "12/31/1969 6:00 PM" where it should be null

Hello all using some mvvm and in my Grid tool that we created in C# anytime a value from the Database is null it populates as "12/31/1969 6:00 PM" someone HELP!!!! :) I really just need it to return a [BLANK] null field

 public enum eColumnType
        {
            @string,
            @int,
            @date,
            datetime,
            time,
            checkbox
        }

Open in new window


     foreach (GridColumn column in this.Columns)
            {
                sb.Append(",{ field: '" + column.field + "'");
                sb.Append(",title: '" + column.title + "' ");
                sb.Append(",width: " + column.Width);

                // Adding Format string for date
                //sb.Append(column.ColumnType == GridColumn.eColumnType.date ? " ,type:'date', format: '{0:MM-dd-yyyy}'" : "");

                switch (column.ColumnType)
                {

                    case GridColumn.eColumnType.datetime:
                        sb.Append(@", template: '#= kendo.formatDateTime(" + column.field + @") #'");
                   
                        break;
                    case GridColumn.eColumnType.date:
                        sb.Append(@", template: '#= kendo.formatDate(" + column.field + @") #'");
                        break;
                    case GridColumn.eColumnType.time:
                        sb.Append(@", template: '#= kendo.formatTime(" + column.field + @") #'");
                        break;
                }

                // Adding Editor function
                sb.Append((column.Editor != null && column.Editor != "") ? " , editor: " + column.Editor : "");

                // Adding checkbox control
                sb.Append(column.ColumnType == GridColumn.eColumnType.checkbox ? " , template: kendo.template($('#" + column.field + "CheckBox" + this.GridID + "').html())" : "");

                sb.AppendLine(" }");
            }
   sb.AppendLine("]\" ");

            //Adding DataSource
            if (this.DataBind != null)
            {
                sb.AppendLine("data-bind=\"" + this.DataBind + "\">");
            }
            else
            {
                sb.AppendLine("data-bind=\"source:" + this.DataSource + "\">");
            }

            sb.AppendLine("</div>");

            return new HtmlString(sb.ToString());

Open in new window

HawaiiDragonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aboo_sCommented:
This is the way DateTime works, it gives you a string represinting a date time.
Now if no value is set or it should be set to zero well this means the start date which is: 12/31/1969 6:00 PM.
So one solution is to compare the returned string with 12/31/1969 6:00 PM to know you have a null!
HawaiiDragonAuthor Commented:
Well being so Green to Kendo how would I do that? Is there a way to change the value so its "blank" on  the date time?
aboo_sCommented:
You can create a string variable, and give it the value "12/31/1969 6:00 PM".
Then just compare your DateTime variable with it.(You might need some casting)
If match then give a third string variable the value of "null" or whatever and return that variable!

It's a workaround, and it's not the neatest!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HawaiiDragonAuthor Commented:
Thank you Aboo,

Exactly what I had to do!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.