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;
}