I have a formView and trying to edit the InsertItemTemplate. There I have a validation control but I can not see the controlTocompare or to validate in the properties list.
Control 'Calendar_EndDate' referenced by the ControlToCompare property of 'CompareValidator_startDate' cannot be validated.
<asp:FormView>
<InsertItemTemplate><asp:CompareValidatorControlToCompare="Calendar_StartDate"ControlToValidate="Calendar_EndDate"...>R</asp:CompareValidator>
<asp:CalendarID="Calendar_StartDate".../>
<asp:CalendarID="Calendar_EndDate".../></InsertItemTemplate>
</asp:FormView>
Is there any way to set the control without using code behind?
In side InsertItemTemplate you want to Give Validation for Calendar control to show Starting date and ending date.So you can do one thing that you set the starDatetextbox of insertitemtemplate with Calender_startdate SelectedDate,Similarly with Enddate then inthe CompareValidator pass the startdateTextbox as comtrolToCompare and EndDateTextbox as controltoValidate.
Try This Hopes this will help...
But Friend For seting the selected date of Calendar Control to the textbox you have to write code in Code behind..as fallows,
protectedvoid Calendar1_SelectionChanged1(object sender,EventArgs e){
if (FormView1.CurrentMode ==FormViewMode.Insert){
TextBox StartDateTextBox = (TextBox)FormView1.FindControl("Start_dateTextBox");Calendar StartDateCalendar = (Calendar)FormView1.FindControl("Calendar1");
// BirthDateCalendar.SelectedDate = BirthDateCalendar.VisibleDate;
StartDateTextBox.Text = StartDateCalendar.SelectedDate.ToString();
}
}
protectedvoid Calendar2_SelectionChanged(object sender,EventArgs e){
if (FormView1.CurrentMode ==FormViewMode.Insert){
TextBox EndDateTextBox = (TextBox)FormView1.FindControl("End_dateTextBox");Calendar EndDateCalendar = (Calendar)FormView1.FindControl("Calendar2");
// JoinDateCalendar.SelectedDate = JoinDateCalendar.VisibleDate;
EndDateTextBox.Text = EndDateCalendar.SelectedDate.ToString();
}
}
After that the Date will come.In compare validator you have to pass two testboxes and in Operator Have to pass "Greaterthen" and in Type "Date"...
Hopes this will help You.
No comments:
Post a Comment