显示数据绑定日期的日历控件
我有一个数据绑定日历控件,可以从数据库加载日期。 我遇到的问题是,加载表单时它默认为今天的日期,尽管当您滚动到加载日期时,您会看到实际上选择了正确的日期。如何强制它从一开始就显示数据库的加载日期?
谢谢
I have a databound calendar control that loads the date from the database.
The problem I have is that it defaults to todays date when the form is loaded, although when you scroll to the loaded date you see that the correct date is in fact selected. How can I force it to show the loaded date from the database from the start?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否正在设置日历
可见
日期?http://msdn.microsoft.com /en-us/library/system.web.ui.webcontrols.calendar.visibledate.aspx
获取或设置指定要在日历控件上显示的月份的 DateTime 值。默认值为 DateTime.MinValue,它显示包含 TodaysDate 指定日期的月份。
你知道,文档是为了阅读而编写的:)
Are you setting the Calendars
Visible
date?http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar.visibledate.aspx
Gets or sets the DateTime value that specifies the month to display on the Calendar control. The default value is DateTime.MinValue, which displays the month that contains the date specified by TodaysDate.
You know, documentation is made for reading :)
我设法找到了解决方法。我在设计时设置了日历控件的 SelectedDate 属性,然后在控件的 Prerender 事件中,使用发送者的 SelectedDate 属性来设置控件的 VisibleDate 属性。然后它会显示正确的月份和正确的所选日期。 :-)
I managed to find a work around. I set the Calendar control's SelectedDate property at design time, and then in the Prerender event of the control, I use the sender's SelectedDate property to set the VisibleDate property of the Control. It then shows both the correct month and correct selected date. :-)