muthukumar Durai

muthukumar Durai

  • NA
  • 20
  • 9.1k

customvalidator inside gridview doesnot work inside gridview

Mar 19 2015 10:40 AM
  CustomValidator custval = new CustomValidator();
            custval = (CustomValidator)sender;


            GridViewRow gvr = custval.NamingContainer as GridViewRow;

            TextBox txtGender = (TextBox)gvr.FindControl("txtGender");
            Label lblRequired = (Label)gvr.FindControl("lblRequired");


            DataTable dt = (DataTable)ViewState["ValidationData"];
            string qry = string.Empty;
            DataRow[] drow;
            qry = qry + " Gender = '" + txtGender.Text + "'";
            //bool _isValid = (string.IsNullOrEmpty(txtNm.Text));

            if (dt.Rows.Count > 0)
            {
                drow = dt.Select(qry);
                if (drow.Length > 0)
                {
args.IsValid=false;
}

else
{
args.IsValid=true;
}