this is compare validator inside gridview
<asp:comparevalidator id="CompareValidator1" runat="server" errormessage="CompareValidator" xmlns:asp="#unknown"></asp:comparevalidator>
<asp:ajaxdatepicker id="UControl2" title="Date Picker" runat="server" xmlns:asp="#unknown"></asp:ajaxdatepicker>
and this is my code behind for setting the control to validate property
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
AjaxDatePicker ajx = (AjaxDatePicker)e.Row.FindControl("UControl1");
TextBox txtDatepicker = (TextBox)ajx.FindControl("txtDatePicker");
AjaxDatePicker ajx1 = (AjaxDatePicker)e.Row.FindControl("UControl2");
TextBox txtDatepicker1 = (TextBox)ajx.FindControl("txtDatePicker");
CompareValidator cmp = (CompareValidator)e.Row.FindControl("CompareValidator1");
cmp.ControlToValidate = txtDatepicker1.UniqueID;
}
}
I am getting the following error on running the page
Unable to find control id 'ctl00$ContentPlaceHolder1$GridView1$ctl02$UControl1$txtDatePicker' referenced by the 'ControlToValidate' property of 'CompareValidator1'.