Simon Cripps
asked on
Using Calendar in Detailsview for insert and update
Hi, I am trying to use a calendar in the detailsview to edit and update a field. However I am running into a couple of problems.
1) The control does not update the records when in update mode. Cade is attached below, I can't see why it does not update.
2) In insert mode as the calendar expects a value I have tried to set the default values in the SQL table to 01/01/2010 - in table definition the "Defalt Value or Binding" is set to (((1)/(1))/(2010)) - However I am getting the error SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM, somehow my defaul value is not being used as I insert,
Can you help resolve these issues on insert/edit calendar date in Detailsview.
1) The control does not update the records when in update mode. Cade is attached below, I can't see why it does not update.
2) In insert mode as the calendar expects a value I have tried to set the default values in the SQL table to 01/01/2010 - in table definition the "Defalt Value or Binding" is set to (((1)/(1))/(2010)) - However I am getting the error SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM, somehow my defaul value is not being used as I insert,
Can you help resolve these issues on insert/edit calendar date in Detailsview.
<asp:TemplateField HeaderText="VCStartDate" SortExpression="VCStartDate">
<EditItemTemplate>
<%-- <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("VCStartDate") %>'></asp:TextBox>
--%> <asp:Calendar ID="Calendar1" runat="server" SelectedDate='<%# Bind("VCStartDate") %>' VisibleDate='<%# Bind("VCStartDate") %>'></asp:Calendar>
</EditItemTemplate>
<InsertItemTemplate>
<%-- <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("VCStartDate") %>'></asp:TextBox>
--%> <asp:Calendar ID="Calendar1" runat="server" SelectedDate='<%# Bind("VCStartDate") %>' VisibleDate='<%# Bind("VCStartDate") %>'></asp:Calendar>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("VCStartDate") %>'></asp:Label>
</ItemTemplate>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have tired to use OnSelectionChanged in the calendar control, however in the code it erros that textBox1 and Calendar1 are not declared. They are both set to runat=server, however it seams that as they are in the detailsview control they cannot be seen.
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calend
Protected Sub Calendar1_SelectionChanged
TextBox1.value = Calendar1.value
How do I get a defaul value abd Selected calendar value to populate the Textbox?
Many thanks in advance for your assistance.