Question
Venkatzeus on Tue, 11 Dec 2012 13:10:22
Hi,
I have a sharepoint datetimecontrol which i am trying to get the date to a datetime field.
Below is the cs code used:
DateTimeControl DtDateRequired = new DateTimeControl(); DateTime RequiredDate = Convert.ToDateTime(((TextBox)(DtDateRequired.Controls[0])).Text); //ObjectOrder.DateRequired is a DateTime Property ObjectOrder.DateRequired = RequiredDate;
In visualwebpart ascx, i have:
<SharePoint:DateTimeControl ID="DtDateRequired" DateOnly="true" runat="server" />
In the below line, i am getting the error:
DateTime RequiredDate = Convert.ToDateTime(((TextBox)(DtDateRequired.Controls[0])).Text);
How to fix this?
Thanks
Replies
Srikanth Nakka on Tue, 11 Dec 2012 13:30:11
Hi
Please refer the below post to work with DateTimeControl
http://karinebosch.wordpress.com/sharepoint-controls/datetimecontrol-control/
You may have to use "SelectedDate" property.
Regards,
Srikanth