Sharepoint日期时间控件不显示页面加载的价值

问题描述:

我在我的一个asp.net自定义页面中使用SharePoint日期时间控件。问题是我试图显示datetime控件中sharepoint字段的值,但它不会在页面加载时显示它。如果我刷新页面,则会显示它。Sharepoint日期时间控件不显示页面加载的价值

<SharePoint:DateTimeControl ID="dtdueDate" DateOnly="True" runat="server" /> 

DateTime dateTime = Convert.ToDateTime(item["DueDate"]); 
((TextBox)(dtdueDate.Controls[0])).Text = dateTime.ToShortDateString(); 

请帮忙吗?

可以使用dtdueDate.LocalId属性格式化日期,在这里:MSDNLocale IDs, Input Locales, and Language Collections for Windows XP and Windows Server 2003或创建自己的DatePicker控件,读到这里:SharePoint DateTime Control Date Format

祝你好运!

应该

dtdueDate.SelectedDate = Convert.ToDateTime(item["DueDate"] == null ? null : item["DueDate"].ToString());