in a grid view how can i apply a validator to check if any of grid view rows with check box are checked or not. i did it using the custom validator like this but giving the error "Control 'GridView1' referenced by the ControlToValidate property of 'gridCheck' cannot be validated. " following is my code what should i do please suggest me the alternate
protected void gridCheck_ServerValidate(object source, ServerValidateEventArgs args)
{
foreach (GridView row in GridView1.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("Chek");
if (cb != null && cb.Checked)
{
args.IsValid = true;
return;
}
else args.IsValid = false;
}
}