简体   繁体   English

在Silverlight中将日期时间绑定到文本框

[英]Binding Datetime to Textbox in Silverlight

I have couple of tables in database with Datatype DateTime and default value getdate() in sql server. 我在数据库中有几个表,数据类型为DateTime,SQL服务器中的默认值为getdate()。 while I am binding this to textbox it is displaying 1/1/0001 as default. 当我将其绑定到文本框时,默认显示为1/1/0001。 I am using Silverlight Ria services. 我正在使用Silverlight Ria服务。

<TextBox Text="{Binding Mode=TwoWay, Path=LST_UPDT_TS, StringFormat=\{0:D\}}"/>

Thank you for helping and for ur time.. 感谢您的帮助和您的时间。

The textbox is displaying the default value for DateTime, which means two things: 文本框显示日期时间的默认值,这意味着两件事:

  1. The Binding worked (else the TextBox would be empty). 绑定工作(否则TextBox将为空)。
  2. The property DateTime LST_UPDT_TS ... has not been set 尚未设置属性DateTime LST_UPDT_TS ...

You should check that the property is being set properly, and that you are binding to the correct instance. 您应该检查属性设置是否正确,以及是否绑定到正确的实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM