Heey
I have a strange error when i try to uppdate my data in db an Error appears( Value of '0001-01-01 00:00:00' is not valid for 'SelectedDate'. 'SelectedDate' should be between 'MinDate' and 'MaxDate'. Parameter name: SelectedDate)
Story: I have a grid in in my UserEditPanel where i try to create users that works perfectly but in this same UserEditPanel there is a little gird where you can add (with new record button) FromDate ToDate WorkingTime and VacationDays for one user that is in same time how to say in creation . if I try to save/update it wont it just reset only in the fields FromDate and ToDate to (0001-01-01 00:00:00') some help would be just awesome btw i'm working with Viewstate
I think that the error appears in this part of the code and i really dont know what is wrong here ...
Code
<telerik:RadDatePicker ID="fromdatepicker" runat="server" DbSelectedDate='<%# Eval("FromDate") == null ? null : Eval("FromDate") %>' TabIndex="4">
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td>To</td>
<td>
<telerik:RadDatePicker ID="todatepicker" runat="server" DbSelectedDate='<%# Eval("ToDate") == null ? null :Eval("ToDate")%>'
TabIndex="4">
</telerik:RadDatePicker>
<asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button> </div> </td> <td> <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancle" OnClick="btnCancel_Click"></asp:Button> </td> </tr> </table> </FormTemplate> </EditFormSettings> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> </telerik:RadGrid> </telerik:RadAjaxPanel> </div> <div class="BackAndSave"> <telerik:RadButton ID="rbBack" CssClass="rowButton" runat="server" Text="Back" OnClick="rbBack_Clicked" CausesValidation="false" /> <telerik:RadButton ID="rbSave" CssClass="rowButton" runat="server" Text="Save" OnClick="rbSave_Clicked" />nothing special just some buttons & fields
code behind
the error appears here (exitingAnnualVacation.FromDate = editedAnualVacation.FromDate;) the second from date is reset
protected void rgAnnualVacation_UpdateCommand(object sender, GridCommandEventArgs e) { try { GridEditableItem item = e.Item as GridEditableItem; Hashtable values = new Hashtable(); item.ExtractValues(values); AnnualVacation editedAnnualVacation = new AnnualVacation(); item.UpdateValues(editedAnnualVacation); //newAnnualVacation.IsNew = true; List<AnnualVacation> annualVacationSource = (List<AnnualVacation>)ViewState["AnnualVacationSource"]; AnnualVacation existingAnnualVacation = annualVacationSource.Where(av => av.AnnualVacationId == editedAnnualVacation.AnnualVacationId).FirstOrDefault(); existingAnnualVacation.WorkingTime = editedAnnualVacation.WorkingTime; existingAnnualVacation.VacationDays = editedAnnualVacation.VacationDays; //Set values to zero when update existingAnnualVacation.FromDate = editedAnnualVacation.FromDate; existingAnnualVacation.ToDate = editedAnnualVacation.ToDate; } catch { //Hier fehlermeldung } }Thanks for help and fast answer !!