RequiredFieldValidator for column
RequiredFieldValidator used to mention the mandatory field or compulsory field. It won’t allow you to leave the field empty. Below is the code to create RequiredFieldValidator dynamically.
RequiredFieldValidator reqfldVal = new RequiredFieldValidator();
reqfldVal.ID = "RequiredValidator10";
reqfldVal.ControlToValidate = "t5";
reqfldVal.ErrorMessage = "City Required";
reqfldVal.SetFocusOnError = true;
e.Row.Cells[4].Controls.Add(reqfldVal);
========================================================
Don't use validation group in aspx page, it is use in .cs page.
Guid gui=guid.New();
reqfldVal.Validationgroup =convert.tostring(gui);
===========================================================
http://www.itprojectsforyou.com/validate_gridview.php
No comments:
Post a Comment