开发者

AspxGridView: How to Convert Date Column Value to Date.ToShortDateString()?

I'm using an editing control for ASPxGridView. It all works fine so far, but I have only one problem. From normal DatePicker, I can se开发者_如何学编程nd the date value without time by ASPxDateEdit.Date.ToShortDateString().

But When I want to do it with the column in my ASPxGrid, the e.NewValues["dateColumn"].ToShortDateString() doesn't work. There is only ToString after dot.

How can I make that happen?


Since e.NewValues["dateColumn"] isn't typed, it's unaware that the value is actually a DateTime, so ToShortDateString isn't available.

You can cast it to DateTime, and then the option will be available for you

((DateTime)e.NewValues["dateColumn"]).ToShortDateString();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜